我想将代码注册到控制器的viewWillAppear
事件,以便稍后在该事件触发时触发。这可能吗?
例如,下面我想注册深度链接的代码以便稍后触发代码,否则我的代码会在viewWillAppear
之前运行得太早:
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject?) -> Bool {
if let storyboard = UIApplication.sharedApplication().keyWindow?.rootViewController?.storyboard,
let controller = storyboard.instantiateViewControllerWithIdentifier("mycontroller") as? MyControllerController {
controller.loadData() // TOO EARLY, how to execute this in the viewWillAppear event?
}
}