I was wondering, if I had maybe 20 or so objects (numbers and strings) that i wanted saved for my app, would it be best to do this in a plist? or NSUserDefaults? or would I need to implement coredata?
Asked
Active
Viewed 116 times
0
-
NSUserDefaults won't be the best place. You can do it with CoreData, save it as a plist or save a file to disk, for example in JSON. – Mark Feb 16 '12 at 17:21
-
Well you can do it with NSUserDefaults if you like. But if you would like to store more complex objects Plists or CoreData would be better options. NSUserDefaults is typically used to store some user data or settings so NSUserDefaults wouldn't be my first choice. – Mark Feb 16 '12 at 17:32
-
right, but the data wont be complex or anything, just maybe 20 ints or so – James Dunay Feb 16 '12 at 17:44
2 Answers
0
I would use NSUserDefaults, if you only have to save 20 strings. it's the fastest way.
You can get an example here: http://www.cocoadev.com/index.pl?NSUserDefaults
You can also save an array in NSUserDefaults if you don't want to store 20 variables.
Anyway, if you have to store more complex objects, plists or coredata would be a better options.
Hope this helps

oriolpons
- 1,883
- 12
- 20
-
-
Take a look at this post: http://stackoverflow.com/questions/537044/storing-custom-objects-in-an-nsmutablearray-in-nsuserdefaults – oriolpons Feb 16 '12 at 18:09
0
NSUserDefaults is mostly used for user préférences if it's app data you need to store, core data is probably the way to go

Ayrad
- 3,996
- 8
- 45
- 86