Jason Rogers
Jason Rogers

Reputation: 19344

IOS: NSUserDefaults Can't find settings on device

I moved some of my apps settings form inside the app to the Settings menu

Everything works fine on the simulator (as usual:D) but when I try to deploy to a device it can't find the settings values in my NSUserDefaults.

In the Settings menu I can see my app and it's settings, but when I run this code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults synchronize];   
    NSString *loc=[defaults objectForKey:@"currency"];
    NSLog(@"start");
    NSLog(@"--- %@",loc);
    [defaults setObject:loc forKey:@"localisation"];

I get :

2012-09-17 15:51:08.240 MyApp[259:707] start

2012-09-17 15:51:08.243 MyApp[259:707] --- (null)

Any Ideas ?

Upvotes: 0

Views: 160

Answers (1)

Jacque
Jacque

Reputation: 820

NSUserDefaults has a method registerDefaults:.

Upvotes: 1

Related Questions