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?
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];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.