I'm having some problems saving to an existing key
//This was previously set and contains this value 1436544831921
NSInteger timestamp = [[NSUserDefualts standardUserDefualts] integerForKey:aKey];
NSInteger newValue = [self doSomethingWithOldValue:timestamp] //returns 1436631948002
[[NSUserDefualts standardUserDefualts] setInteger:newValue forKey:aKey];
[[NSUserDefualts standardUserDefualts] synchronize];
Is something wrong with this implementation? It is not saving but persisting the previously saved value.
Try setting your NSUserDefaults
first like this:
NSUserDefaults *userPrefs = [NSUserDefaults standardUserDefaults];
You can also try to use a NSString like this:
NSInteger newValue = [self doSomethingWithOldValue:timestamp];
NSString* newValueString = [NSString stringWithFormat:@"%i", newValue];
[userPrefs setObject:newValueString forKey:aKey];
Also make sure that your aKey
is set correctly
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With