0

What event/selector/method is called, if any, when the user closes the app in the multi-tasking screen? Xcode reports Message from debugger: Terminated due to signal 9 (i.e. SIGKILL, which cannot be trapped). Is the use of AppDelegate.applicationWillResignActive,which is invoked when the user pressed the 'Home' button, the next best option?

closed as off-topic by Tetsujin, grg, Mark, nohillside Apr 23 '17 at 11:14

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here, but can be asked on Stack Overflow." – Tetsujin, grg, Mark, nohillside
If this question can be reworded to fit the rules in the help center, please edit the question.

0

It depends on the state your app is in:

If your app is suspended (i.e. it is in the background and not currently executing), there's no way of detecting the user closing the app.

If your app is backgrounded (i.e. it is in the background and executing), then your applicationWillTerminate method will be called.

  • This is a bit tricky to arrange though as the UI is event driven. Some sort of background task (like a watchdog) could be used? Without something constantly running, it's difficult to 'clean up' properly. – gone Apr 23 '17 at 16:46
  • No, you cannot use a watchdog or anything similar to stay in the backgrounded state. This is beyond the control of the app. What is it exactly you want to "clean up"? – jksoegaard Apr 23 '17 at 21:17
  • I want to save the data in the app before it is closed. – gone Apr 25 '17 at 11:41
  • @gone You cannot do that. You'll have to save periodically during program execution. – jksoegaard Apr 25 '17 at 11:45
  • That's unfortunate. Swiping up is not the same thing as pressing Ctrl-C to quit a malfunctioning program. – gone Apr 26 '17 at 3:27

Not the answer you're looking for? Browse other questions tagged .