简体   繁体   中英

Storing data in NSUserdefaults or coredata?

  1. I need to store a dictionary in my app It's life time should be as same as life time of the data stored in NSUserDefaults.

  2. There are few ways to achieve but I am thinking of core data , NSKeyedArchiever and NSUserDefaults .

  3. I am going to update this information frequently and also dictionary is not going to be a large data .

  4. My question is which method is best? because storing and retrieving from NSUserDefault is costly operation.

- Core Data seems overkill and is really meant to manage larger amounts of data. It would require you to maintain the entire Core Data stack with persistent store, context, model etc.

- NSKeyedArchiver is not meant for frequent changes and certainly much more code than NSUserDefaults.

+ NSUserDefaults is best for the scenario you describe. It is a simple, transparent and sanctioned API, has a fast underlying database associated with it, can be synched via iCloud etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM