Call app delegate method from view controller
Not sure why you want to do this. You probably shouldn't, but for the purpose of answering the question here it is:
// get a reference to the app delegatelet appDelegate: AppDelegate? = UIApplication.shared.delegate as? AppDelegate// call didFinishLaunchWithOptions ... why?appDelegate?.application(UIApplication.shared, didFinishLaunchingWithOptions: nil)
In Swift 3.0, you can call as:
let appDelegate = UIApplication.shared.delegate as! AppDelegateappDelegate.anyAppDelegateInstaceMethod()
This method is called just once when app launches. You can't from ViewController. Instead make user defined method in AppDelegete. and call that method from ViewController. By getting object of AppDelegate.
AppDelegate *appDel = (AppDelegate *)[UIApplication sharedApplication].delegate;[appDel <Your method>];