best practice for dealing with saving/loading preferences.
best practice for dealing with saving/loading preferences.
- Subject: best practice for dealing with saving/loading preferences.
- From: Memo Akten <email@hidden>
- Date: Fri, 3 Apr 2009 22:00:17 +0100
I have an iphone app that runs at 60fps. I have all of my settings
(about 10-15) stored in an NSMutableDictionary. When changes are made
from the UI, the relevant NSNumber in the dictionary is updated. My
update loop (which runs at 60fps) reads the settings directly from the
dictionary (once per frame).
I now want to save/load these settings as well. I know how to use
NSUserDefaults so my question isn't a syntax question but more which
is the preferred mefthod. I see a number of options:
- dont even use NSUserDefaults but just save the NSMutableDictionary
directly with writeToFile:atomically: when the application exits (And
read at startup)
- write the dictionary to NSUserDefaults as a single entity
[[NSUserDefaults standardUserDefaults] setObject:settingsDict
forKey:"@MySettings"] when application exits (and create mutable copy
at startup)
- scrap my dictionary, and just use NSUserDefaults. When a setting is
changed in the UI, immediately [[NSUserDefaults standardUserDefaults]
setFloat:forKey:], and in the update loop read settings
[[NSUserDefaults standardUserDefaults] floatForKey:@"setting1"];
Is there any one of these that is particularly recommended or advised
against?
Cheers,
Memo.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden