I may have found a bug in the simulator. NSUserDefaults cannot remove a key from memory permanently. I have this code:
Code:
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER];
...
}
// Function that gets called later in the code
NSMutableArray *temp = [[NSUserDefaults standardUserDefaults] objectForKey:KEY_IDENTIFIER];
NSLog(@" Delegate: Array = %@", temp);
When I run this code, it will display temp = nil (as expected). Then, I close the simulator and uncomment the line of code that removes the object from NSUserDefaults and I build the code again. The value of temp is
not nil. It equals the values that were stored in [[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY_IDENTIFIER] from a previous time.
Is this a bug, or am i missing something huge?