I am new to iOS, so please spare me if i am asking something thats known to everyone or something wrong.
I need to save some Arrays and links in my app. So i used NSUserDefaults
instead of Database. I know that NSUserDefaults
holds the values until we uninstall the app or somehow clear the app data. So I just need to know, Is is ok to use NSUserDefaults
instead of using database?
Thread SafetyThe UserDefaults class is thread-safe.
When to Use User Defaults? The defaults system is ideal for storing small chunks of data, such as settings or the user's preferences. The user's defaults database is stored on disk as a property list or plist. A property list or plist is an XML file.
A property list, or NSUserDefaults can store any type of object that can be converted to an NSData object. It would require any custom class to implement that capability, but if it does, that can be stored as an NSData. These are the only types that can be stored directly.
NSUserDefaults are stored in plist in binary format, with no encryption, and is stored in your app's directory.
When I store data:
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