Currently, I'm developing an app that functionality heavily relies upon retrieved JSON data. Most of the data I'm planning to save into core data. However, not sure do I have to save all user related stuff (settings, favorites, twitter, Facebook and ect.) also in core data, or should I use NSUserDefaults? What are pros and cons?
Core Data is unnecessary for random pieces of unrelated data, but it's a perfect fit for a large, relational data set. The defaults system is ideal for small, random pieces of unrelated data, such as settings or the user's preferences.
If your project requires encryption or speed, then Realm is an obvious choice. If your project has a complex data model that changes frequently, then Core Data might be a better choice.
It appears the limit is the maximum file size for iOS (logically), which is currently 4GB: https://discussions.apple.com/thread/1763096?tstart=0. The precise size of the data is circumscribed by the compiler types (NSData, NSString, etc.) or the files in your asset bundle.
The persistent store should be located in the AppData > Library > Application Support directory.
You can refer to Apple's own guide: Implementing Application Preferences
you can store the user setting in any way as you want :The choice between NSUserDefaults and Core Data is just between API, where the former was actually designed to handle user preferences.
NSUserDefaults and the "built-in settings component" are really one and the same. Using the settings app will still store preferences in NSUserDefaults which you access in your app with that API.
The reason why you might not want to use the built-in settings app would be: It's cumbersome for users to change those settings. If you have settings that users might want to change frequently, you might want to do that inside your app (e.g. turning music on/off, changing player name). Also, since you have full control over your own app, you can have a more flexible GUI than the one Apple provides in Settings.app
As for using Core Data or NSUserDefaults... i would say go with NSUserDefaults as it is much easier to implement and was designed to do this, where as implementing core data will take a lot of effort.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With