Tushar Chutani
Tushar Chutani

Reputation: 1570

What method is called when iPhone app is terminated?

I am making a client server application for the iPhone and would like to know which method is called when the iPhone application is terminated. Any help would be appreciated.

Upvotes: 1

Views: 1650

Answers (4)

Ortwin Gentz
Ortwin Gentz

Reputation: 54113

-(void)applicationWillTerminate:(UIApplication *)application in your application delegate will be called. Check this blog post with chart that describes in detail what messages will be sent during launch, termination and when transitioning between background and foreground.

Upvotes: 0

Perception
Perception

Reputation: 80598

The method applicationWillTerminate gets called when your application is being shut down. But the applicationDidEnterBackground/applicationWillResignActive methods are (now) infinitely more useful.

Upvotes: 0

ArunGJ
ArunGJ

Reputation: 2683

- (void)applicationWillTerminate:(UIApplication *)application

in your appdelegate

Upvotes: 0

Benjamin Mayo
Benjamin Mayo

Reputation: 6679

The method relating to application lifecycle are UIApplicationDelegate methods. The two you want are:

- (void)applicationWillTerminate:(UIApplication *)application
- (void)applicationDidEnterBackground:(UIApplication *)application

If on a multitasking device, applicationDidEnterBackground: will be called instead of applicationWillTerminate:. In most cases, you can perform the same code in both callbacks.

Upvotes: 6

Related Questions