简体   繁体   中英

iOS Simulator: Application can't terminate correcly

I have an application that when terminated needs to synchronize the content of a sqlite database.
To know when the application is terminating, I put a breakpoint in the app delegate's applicationWillTerminate: method.But the debugger never steps there.
I know two methods to terminate the application:

  1. Like I do in the iPhone: Keep touching the application icon until it starts trembling, the I click on 'x';
  2. Stopping the debugger.

None of these two methods cause the debugger to step in the applicationWillTerminate: method of my app delegate.
If I use the first method I even get an exception: I receive SIGKILL right in this line:

return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

It seems like the simulator launches SIGKILL even if there isn't a handler for that signal.
The last message called is mach_msg_trap.

From the documentation

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.

You probably want applicationWillResignActive: .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM