Sharing parameters between setting view and application view
Simple question : I've got an iPhone app with 2 views with each a separated xib files. one view holds the settings of the app one view holds the app using the settings made in previous view.
How should I implement the sharing of setup p开发者_JS百科arameters between the 2 views ? should I manage those parameters in the app delegate ?
You can save the settings in the user defaults using
[[[NSUserDefaults] standardUserDefaults] setObject:blah forKey:@"blah"];
Then in the other view, just get the values from the user defaults with
[[NSUserDefaults] standardUserDefaults] objectForKey:@"blah"];
The NSUserDefaults class keeps the objects in memory and writes them out to disk at certain periods. So you don't have to worry about hitting the disk too often.
精彩评论