I’m writing an app that uses many ViewControllers.
Is there anyway I can detect applicationWillResignActive on these ViewControllers rather than passing that event from the AppDelegate class? (i.e [self.viewController1 suspend] etc)
Some of the ViewControllers might not have been instantiated yet and I’d have to do too many if else from the default AppDelegate handler to pass the event to every single possible ViewControllers.
I tried adding the below code snippets but doesn’t seem to do the trick.
In the ViewController’s viewDidLoad method
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(foo) name:@"AppResigned" object:nil];
In the AppDelegate default applicationWillResignActive method
[[NSNotificationCenter defaultCenter] postNotificationName:@"AppResigned" object:nil];
Thanks,
Tee
When I moved the addObserver to init it works. Weirdness.