access view controller instance in appdelegate swift code example
Example 1: swift access appdelegate from viewcontroller
func appDelegate() -> AppDelegate {
return UIApplication.shared.delegate as! AppDelegate
}
Example 2: swift access appdelegate from viewcontroller
let appDelegate = UIApplication.shared.delegate as! AppDelegate
let aVariable = appDelegate.someVariable