【发布时间】:2016-12-07 15:03:00
【问题描述】:
我想在第一次启动应用程序时调用一个 API,在 AppDelegate 类 didFinishLaunchingWithOptions 中,并在响应后开始所有执行。
【问题讨论】:
-
请edit你的问题表明你已经尝试过。
我想在第一次启动应用程序时调用一个 API,在 AppDelegate 类 didFinishLaunchingWithOptions 中,并在响应后开始所有执行。
【问题讨论】:
我猜你想进行网络调用(例如检查应用程序版本),等待响应,然后根据响应,从正确的视图启动应用程序。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let startupVC = // Create a temporary view controller in Storyboard or XIB (can be the same as your launch view controller)
self.window.rootViewController = starupVC
self.window.makeKeyAndVisible()
networkCallWithReponseBlock {
let startingViewController = // your view controller from Storyboard, XIB or code
self.window.rootViewController = startingViewController
}
return true
}
【讨论】: