Is it possible to run a function defined in a view controller from the AppDelegate
function applicationWillEnterForeground
? If so, how? I am trying to do this in applicationWillEnterForeground
but vc
is nil
.
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
return true
}
func applicatioWillEnterForeground (_ application: UIApplication) {
if let vc = window?.rootViewController as? ViewController {
vc.resetValues()
}
}