Reputation: 1371
I'm trying to save the data from a viewController. I'm doing this by using the delegate methods in the appDelegate: - (void)applicationDidEnterBackground:(UIApplication *)application
The problem is when using storyboards, the viewControllers automatically get set up for you and I'm not sure how to get a pointer to them so that I can access their data for saving.
How can I get a pointer to them in appDelegate while using storyboards?
Upvotes: 0
Views: 491
Reputation: 9453
You can register to receive going to and from background notification inside your UIViewController
and manage the saving there.
//Going into background
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(saveData) name:@"UIApplicationDidEnterBackgroundNotification" object:nil];
//Waking up
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(doSomethingOnWakeup) name:@"UIApplicationWillEnterForegroundNotification" object:nil];
Upvotes: 1