开发者

Serialize CGAffineTransform to store in NSUserDefaults

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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜