我的“didFinishLaunchingWithOptions”如何等到调用api完成之后

时间:2016-04-16 19:46:51

标签: ios swift api

我的应用程序如何等到我的呼叫api完成后才能结束?

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    GMSServices.provideAPIKey("AIzadGlsfR35k4BeHCXmRq3GDSQ-l_5gcD8")
    FlicAuth.sharedInstance

    //Call Api here

    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil))
    application.registerForRemoteNotifications()

    if(launchOptions?[UIApplicationLaunchOptionsLocationKey] != nil){
        LocationService.sharedInstance.startMonitoringLocation()
    }

    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

提前感谢

1 个答案:

答案 0 :(得分:4)

这是非常错误的,但对于你的问题,我有一个更好的解决方案。

创建一个与启动画面完全相同的viewController并设置为初始viewController ..在该viewController的类中执行操作,在Api成功后,您可以导航到实际屏幕或以编程方式更改根