Hi, i got a problem in [NSUserDefaults standardUserDefaults]
in iOS4.0.
I saved some states by using [[NSUserDefaults standardUserDefaults] setObject:self.listData forKey:@"listData"];
in applicationDidEnterBackground:
and applicationWillTerminate:
methods. And i retrieved the data by using NSMutableArray *listData = [[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:@"listData"]];
in the viewDidLoad
method.
I'm using sdk4.1 and simulator to test. The problem is: it does call the save method when my app enter the background. Since i want to know whether it's really been saved, so i double click the home button to call the multitask stack and hold the home button, then use the minus icon to kill my app in the background. Then i enter the app again, but the data didn't actually be saved.
Then i select the property Application does not run in background in the info.plist to see if it works in iOS3.0. And when i hit home button, it called the save method, then i enter the app, the data has been saved successfully.
So i'm wondering how the [NSUserDefaults standardUserDefaults]
works in iOS4.0? How could i possibly save some data by using it in iOS4.0? Many thx!