pass data by notification center appdelegate swift to viewcontroller 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