I want to store an array with NSUserDefault
, then, I put in applicationDidEnterBackground
[[NSUserDefaults standardUserDefaults] setObj
Store the object in NSUserDefaults
in -applicationWillTerminate:
, if it hasn't already been saved by the invocation of -applicationDidEnterBackground:
(i.e. check if multitasking is supported, if it is, then don't save it because it's already been saved.)
- (void) applicationWillTerminate:(UIApplication *) app {
if([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)] &&
![[UIDevice currentDevice] isMultitaskingSupported]) {
[[NSUserDefaults standardUserDefaults] setObject:myArray forKey:@"myArray"];
}
}