开发者

NSUserDefaults and NSMutableArray

开发者 https://www.devze.com 2023-03-12 06:15 出处:网络
When saving an array in the userdefaults开发者_Go百科 using the setObject method, is it then ok to just setObject:myMutableArray or do I need to wrap it in

When saving an array in the userdefaults开发者_Go百科 using the setObject method, is it then ok to just setObject:myMutableArray or do I need to wrap it in

[NSArray arrayWithArray:myMutableArray]; ? The first one should work right? Since it is a subclass of NSArray, and it wont affect other things?


There's not a problem with what you're trying to do, however bear in mind that when you get an object back from user defaults you always get it immutable.

A nice approach can be found here to make it easy to work it.

0

精彩评论

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