title: iOS Save State when device turns off or battery drains
body: <p>I have an app that syncs records created on the phone with a web-server.</p>
  
  <p>When app does not have internet connectivity, it store everything locally (Core Data) and then syncs it when internet is available again.</p>
  
  <p>Now a user has come up with a valid user case scenario ... say he is in an airplane making records (without network) ... so everything is getting stored locally. All is well till the air hostess commands him to switch off the phone. While in the app he immediately turns if off. Now the data is getting lost. I am saving sate while app goes in background or even when phone is locked. But how do I warrant for this? </p>
  
  <p>When user switches off the phone (long-pressing lock button), they still have to slide a bar and devices takes some time before switching off ... so there is some time I can save state in ... which delegate method is called during this time?</p>