Best practice for applicationDidEnterBackground [closed]
-
16-11-2019 - |
Question
I am in the middle of writing an application that needs to reset certain parts of its state to a default state when the application calls applicationDidEnterBackground. What I would like to know is if it is a better practice to get a pointer to the view that needs to be reset and then reset the properties that need to be reset right there in the app delegate, or should I post an NSNotification that the app is entering the background and have the view controller do it's cleanup within itself. Or maybe there's another method I'm not thinking of.
I appreciate any input.
Solution
These notifications get posted already. Just subscribe to the event in your controller class(es) and do whatever you need to there.
From the docs:
The application also posts a UIApplicationDidEnterBackgroundNotification notification around the same time it calls this method to give interested objects a chance to respond to the transition.