How do you encode and decode a CGPoint struct using NSCoder?
How do you encode and decode a CGPoint struct using NSCoder ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
CGPoints andNSPoints are both structures composed of twoCGFloatvalues, so you can freely pass them around as each other. The quick and dirty way would be:This will usually work, but it technically breaks the C99 strict aliasing rules. If you want to be 100% compatible with the standard, you’ll have to do something like: