チェックこのコードで
func applicationDidEnterBackground(_ application: UIApplication) {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate,
let controller = appDelegate.window?.rootViewController as? FirstViewController {
controller.refreshItems()
}
}
func applicationWillEnterForeground(_ application: UIApplication) {
if let appDelegate = UIApplication.shared.delegate as? AppDelegate,
let controller = appDelegate.window?.rootViewController as? FirstViewController {
controller.refreshItems()
}
}
(FirstViewControllerが他のウィンドウのrootViewControllerがnullをAppDelegateにFirstViewControllerのインスタンスを取り、確認している場合)のObjective-C
- (void)applicationDidEnterBackground:(UIApplication *)application {
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
FirstViewController *controller = (FirstViewController*)[[appDelegate window] rootViewController];
[controller refreshItems];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
AppDelegate *appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;
FirstViewController *controller = (FirstViewController*)[[appDelegate window] rootViewController];
[controller refreshItems];
}
私はObjective - Cで必要です – kiran