sometimesiwritecode
sometimesiwritecode

Reputation: 3213

Is there a way to guarantee the running of some code whenever an iOS app closes?

I tried putting my code in the applicationWillTerminate function of the app delegate but noticed it wasn't being called when I closed the app and then read up and found out applicationWillTerminate is not called consistently on app close. What the heck?

Is there any way to consistently execute code on app close? It seems like a simple requirement and it is important for my project so I hope this is possible.

Upvotes: 2

Views: 151

Answers (1)

Duncan C
Duncan C

Reputation: 131398

applicationWillTerminate is not normally called. You get a message when your app is about to be suspended, and once that happens you can be terminated without further warning. you should treat a suspend event as a possible termination and save everything you need to save.

As I recall it is possible to get notified about UNIX SIGTERM messages, but I'm not positive.

Upvotes: 2

Related Questions