applicationWillTerminate: not being called

TheHAWK picture TheHAWK · Sep 14, 2011 · Viewed 8.3k times · Source

I'm using applicationWillTerminate: to save some last-minute stuff. But the problem is that it never gets called. If I do something like this at the top of the method: NSLog(@"Something"); it doesn't get called and doesn't get outputted to the console.

Does anyone know why this is happening?

Answer

zaph picture zaph · Sep 14, 2011

From Apple docs:

For applications that do not support background execution or are linked against iOS 3.x or earlier, this method is always called when the user quits the application. For applications that support background execution, this method is generally not called when the user quits the application because the application simply moves to the background in that case. However, this method may be called in situations where the application is running in the background (not suspended) and the system needs to terminate it for some reason.

If your app has background enabled use:

- (void)applicationDidEnterBackground:(UIApplication *)application