dimanche 6 mars 2016

NSUserDefaults returns null after registerUserDefaults worked previously

My code worked before, now it doesn't for some reason. I was testing on device, then I removed the app and tested with Test Flight. Now the defaults fail to register.

    NSDictionary *appDefaults = @{
                    [NSNumber numberWithInt:50]: @"DidBuyInAppPurchase",
                    [NSNumber numberWithInt:0]: @"AdShow"
                    };
NSLog(@"appDefaults %@", appDefaults);
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
[[NSUserDefaults standardUserDefaults] synchronize];

NSLog(@"user default ad show %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"AdShow"]);

Logs show

appDefaults { 0 = AdShow; 50 = DidBuyInAppPurchase; }

so that dictionary is being created just fine. And then logging the key:

user default ad show (null)

Aucun commentaire:

Enregistrer un commentaire