Проверьте этот код (если FirstViewController является RootViewController окна еще взять экземпляр FirstViewController в AppDelegate и проверить нуль)
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()
}
}
в 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