开发者

How much is too much to store in NSUserDefaults?

开发者 https://www.devze.com 2023-03-31 09:16 出处:网络
NSUserDefaults is such an easy and convenient way to persist data on a device, and while it is encouraged as use for basic settings, I wonder, is there a practical limit to what you should use it for?

NSUserDefaults is such an easy and convenient way to persist data on a device, and while it is encouraged as use for basic settings, I wonder, is there a practical limit to what you should use it for?

Suppose you have a large dictionary of many objects, 1000, and each of those objects is itself a dictionary with simple text strings as values. Overall, this big dictionary is probably not too large, since it only contains text, even if a fair amount of it.

Is it O.K. to use NSUserDefau开发者_运维知识库lts for something like this, your main data model?


Why not just store that as an NSDictionary in a file?

See this post for a nice way to save your file as a plist: Save NSDictionary to plist

and getting it back is as easy as this:

NSDictionary *dict = [NSDictionary dictionaryWithContentsOfFile:fileName];
0

精彩评论

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