What is the Exit point of iphone application
Please any one can tell me what is the exit point of application? I have developed an app, in this app I have passes an array in all views(used in whole applicat开发者_如何学编程ion), an its running perfectly. But I want to release this array when app exits.
Thanks.
In iOS with multitasking, you don't have a clear exit point. You application can be killed at any time without notice if it is in the background. So if you have settings to save, you need to do so in the app delegate methods applicationWillTerminate:
(iOS without multitasking) and applicationDidEnterBackground:
(iOS with multitasking). It's also a good idea to save on applicationDidResignActive:
. See the UIApplicationDelegate reference.
Note that all of these events also post NSNotifications to which you can subscribe to in any class you like. See the notifications section in the UIApplication reference.
As for releasing your array: you should release all your data in your classes' dealloc
methods (yes, same applies for the app delegate).
- (void)applicationWillTerminate:(UIApplication *)application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground:.
*/
}
this in your app delegate class.
The dealloc
in your App delegate should do it. Just add
- (void)dealloc
{
[yourArray release];
}
in your app delegate....
The array will be automatically released when the app exits, as the system reclaims all the app's memory. You don't need to worry about it.
精彩评论