0

I need to store some single value, like logged in user's id from server or for example flag that application was launched for the first time. This info has to be stored persistently and there should be thread safety of course. What is the best method to do that? As I understand, there are at least two persistent storage technologies - NSUserDefaults and Core Data. First one is not supposed to do what I need, i.e. it's supposed to store user preferences, not technical data, and second one is supposed to store relational entities in quantities larger than 1, AFAIK.

Is there any other technologies to persistently store application data with thread safety? Am I supposed to learn about Core Data further more?

DemoniacDeath
  • 1,778
  • 3
  • 13
  • 25

2 Answers2

3

NSUSerDefaults is what you need to use. You can save data's there as long as there is no confidential information.. Please don't use NSUserDefaults to save things like password etc. For that use Keychain services.

Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
1

Use NSUserDefaults. It's not just for user preferences. You can store any setting, option, flag or data in there. It just shouldn't be too much (like thousands of entries or more) for performance reasons.

You could also simply write a file to the user's documents folder. NSSString, NSArray and NSDictionary all have methods to be written to or read from files.

DrummerB
  • 39,814
  • 12
  • 105
  • 142