In order for the ViewController
to "do something specific" just before the app goes into the background state...
I am to understand that this sort of thing is generally handled inside the
applicationWillResignActive(_:)
method, but this method resides inside the AppDelegate
class, not the ViewController
.
This is my first time doing lifecycle related stuff on IOS, and so I'm not sure whether to:
1) Call a ViewController
method from inside the AppDelegate
class. This would mean that I have to change the method from private to public.
2) Have the ViewController
implement UIApplicationDelegate
PS - Is it okay to just delete the AppDelegate
class as long as the ViewController
implements UIApplication
delegate instead?
EDIT: I should add that this is a single-page app with only one view controller (well, I suppose it will have a settings view controller eventually... but the 'ViewController' that I am referring to will never be popped off the stack).
Thanks!