Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone SDK - load/save settings
    text
    copied!<p>I have the following two procedures defined in my AppDelegate. saveSettings and loadSettings. I am calling my loadSettings procedure in the AppDidFinishLaunching method, and I am calling the saveSettings procedure in my settings view, once the save button is clicked.</p> <p>Both methods seem to be called at the right time, the right number of times (once), and using the correct data. my settings object gets the right data, but the data does not seem to be actually saving. When I run the load code, my resulting variables are coming back empty (not nil).</p> <p>I tried putting the same loading code in a different view and it works fine, but for some reason, I am not getting results in my appDelegate. </p> <p>Any Help would be greatly appreciated.</p> <pre><code>- (void)applicationDidFinishLaunching:(UIApplication *)application { [window addSubview:navigationController.view]; [window makeKeyAndVisible]; [self loadSettings]; [self setDefaults]; } -(void)loadSettings{ NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; settings.masterLocation = [prefs objectForKey:@"masterLocation"]; settings.masterPort = [prefs objectForKey:@"masterPort"]; settings.userName = [prefs objectForKey:@"userName"]; settings.passWord = [prefs objectForKey:@"passWord"]; settings.autoLogin=[prefs objectForKey:@"autoLogin"]; if (settings.autoLogin == nil) settings.autoLogin=@"N"; } -(void)saveSettings:(SharedData *)d{ settings=d; NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setObject:settings.masterLocation forKey:@"masterLocation"]; [prefs setObject:settings.masterPort forKey:@"masterPort"]; [prefs setObject:settings.userName forKey:@"userName"]; [prefs setObject:settings.passWord forKey:@"passWord"]; [prefs setObject:settings.autoLogin forKey:@"autoLogin"]; } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload