开发者

sth about applicationWillTerminate

开发者 https://www.devze.com 2023-01-08 21:34 出处:网络
- (void)applicationWillTerminate:(UIApplication *)application { NSLog(@\"applicationWi开发者_JAVA百科llTerminate\");//======>1
- (void)applicationWillTerminate:(UIApplication *)application {
  NSLog(@"applicationWi开发者_JAVA百科llTerminate");           //======>1    
}

- (void)dealloc {
  NSLog(@"dealloc");                           //=======>2
  [window release];
  [super dealloc];
}

why don't 1& 2 textout the msg when i quit this program with debug???


When you say "quite with debug," what do you mean? Is this as standard quit (Cmd-Q for instance), or are you hitting the Stop button in Xcode? Is this method in your application delegate? Does it run in Release mode?

Regarding #2, there is no guarantee that -dealloc will be called, and it is standard procedure to skip it on program termination to speed things up (the OS will reclaim all memory anyway). It shouldn't be doing much more other than releasing memory for exactly that reason.


i got it (from apple)

this method(applicationWillTerminate)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.

In iOS 4.0 and later, this method is called instead of the applicationWillTerminate: method when the user quits an application that supports background execution. You should use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. You should also disable updates to your application’s user interface and avoid using some types of shared system resources (such as the user’s contacts database). It is also imperative that you avoid using OpenGL ES in the background.

0

精彩评论

暂无评论...
验证码 换一张
取 消