Seems a simple question, but I'm not able to find an answer. I have some user information that I want to save locally using NSUserDefaults whenever the user presses the home button. I've read that I should put this in the appdelegate classes applicationDidEnterBackground method. But how do I make the actual data to be saved (in the view controllers) available to the applicationDidEnterBackground method? Thanks for the help.
Asked
Active
Viewed 119 times
1 Answers
1
You have the right idea, but the code doesn't have to be in the app delegate. You can observe the notification that is sent when the application enters the background from anywhere and save your data when this notification is received.

Abizern
- 146,289
- 39
- 203
- 257
-
Have a look at the NSNotificationCenter documentation. There are many examples in that. – Abizern Sep 28 '15 at 08:14