views:

32

answers:

1

I have just uploaded my app and it was accepted. To my horror, I now discover that if I hold down the top right button for some time, to turn iPhone off and then repeat that to turn it on again (i.e. a hard reset), the contents of Documents has vanished.

A: 

Since the upgrade to 4.x, this is no longer called:

- (void)applicationWillTerminate:(UIApplication *)application {
}

and my data was not being saved any more (but it still "worked" in a qhostly fashion). The fix was to redo my save in this new method:

- (void)applicationDidEnterBackground:(UIApplication *)application {
}

and other changes in this one:

–(void)applicationWillEnterForeground:(UIApplication *)application {
}

After first registering them in viewDidLoad like this:

UIApplication* app = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillTerminate:)
name:UIApplicationWillTerminateNotification
object:app];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationDidEnterBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:app];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:UIApplicationWillEnterForegroundNotification
object:app];
Robin Pain