tags:

views:

29

answers:

1

Hi there, 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 parameters between the 2 views ? should I manage those parameters in the app delegate ?

+2  A: 

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.

Rengers
Excellent, thanks a lot. Do you mean that the user will find back his settings when coming back later in the app ?
Tibi
Yes, NSUserDefaults will write the settings to disk with a certain interval. It will also do this when the app terminates gracefully and when you call `[NSUserDefaults synchronise]`You need to retrieve the values from the defaults using `objectForKey` and then update your UI accordingly.
Rengers