How would I store a CGAffineTransform in NSUserDefaults? Since it contains 6 float values it takes a lot of repetitive work to store each value as float... so I开发者_如何学C'm wondering if there is a smarter way.
Use NSStringFromCGAffineTransform() and CGAffineTransformFromString().
Using NSValue, I got:
-[NSUserDefaults setObject:forKey:]: Attempt to insert non-property value 'CGAffineTransform: {{0.9291659, 0, 0, -0.9291659}, {41.675232, 823.75122}}' of class 'NSConcreteValue'. Note that dictionaries and arrays in property lists must also contain only property values.
Wrap it in an NSValue
instance:
NSValue *affineTransformValue = [NSValue valueWithCGAffineTransform:myTransform];
精彩评论