The "correct" place to save state is in both -applicationDidEnterBackground:
and -applicationWillTerminate:
. Don't worry about double-saving; generally only one of them is called (IME, -applicationWillTerminate:
is not called when your app is killed in the background).
Caveat: -applicationDidEnterBackground:
is not guaranteed to be called, since it is called after your app enters the background (and thus becomes eligible for killing without notice!). If the device is low on memory when your app is backgrounded, it might be killed. The best way to avoid this is to not use too much memory in the first place.
You could use
-applicationWillResignActive:
, but I do not recommend this: apps become inactive quite frequently. An obvious is system dialogs (location/privacy prompts, Wi-Fi, notifications that show as alerts, alarms), TWTweetSheet, and I suspect MFMailComposeViewController, MFMessageComposeViewController, Notification Center, the app-switcher bar (e.g. to change tracks/enable orientation lock).