开发者

How to save an NSMutableArray containing NSMutableArrays of custom objects in NSUserDefaults

开发者 https://www.devze.com 2023-01-20 11:42 出处:网络
I was able to save an NSMutableArray of custom objects to NSUserDefaults by implementing NSCoding in the custom class. However, now I want to save an NSMutableArra开发者_StackOverflow中文版y of these

I was able to save an NSMutableArray of custom objects to NSUserDefaults by implementing NSCoding in the custom class. However, now I want to save an NSMutableArra开发者_StackOverflow中文版y of these arrays. The compiler complains when I try to do this. How can this be done?


I found out how to do it. Basically, your transform the array into a data object using NSKeyedArchiver, and that is what you save with NSUserDefaults. Then when you get the data object back, you use NSKeyedUnarchiver to turn it back into an array.

0

精彩评论

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