TdoubleG
TdoubleG

Reputation: 489

iOS 8.0: NSUserDefaults resets

Since iOS 8.x the UserDefaults has a strange behavior. Whenever I "quit" my app via the app-switcher my userdefaults gets reseted.

On iOS 7.x it works like a charm, so hope you guys can help me.

Some Code from the App Delegate:

    if ([[NSUserDefaults standardUserDefaults] objectForKey:@"FirstStart"])
    {
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"FirstStart"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
    else
    {
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"FirstStart"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

This is one example. I have some more code snippets, where I store something to the userdefaults (mostly bools) and everytime it's reseted.

When I start from xCode there is no problem.

What could be the problem?

Upvotes: 0

Views: 283

Answers (1)

TdoubleG
TdoubleG

Reputation: 489

KILL ME!!!

In my AppDelegate Method applicatinWillTerminate:application I called

NSString *appDomain = [[NSBundle mainBundle] bundleIdentifier];

[[NSUserDefaults standardUserDefaults] removePersistentDomainForName:appDomain];

I don't know why I remove the UserDefaults but anyway now it works fine!

Upvotes: 2

Related Questions