Get applicationDidFinishLaunching call in a View Controller. Parse not initialized yet

青春壹個敷衍的年華 提交于 2019-12-25 06:39:41

问题


I am trying to load data from Parse in my Initial View Controller. The issue is that Parse is initialized in my AppDelegate's didFinishLaunching so I need to wait until it is called before I attempt to load the data from Parse. What is the best way to get this notification in my view controller? Or would it be better to get the data in my AppDelegate?

All help is appreciated!


回答1:


You can add an observer for the UIApplicationDidFinishLaunchingNotification inside your view controller viewDidLoad method:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "yourMethod:", name: UIApplicationDidFinishLaunchingNotification, object: nil)

Add your method to the view controller

func yourMethod(notification: NSNotification?) {
    // your code
}


来源:https://stackoverflow.com/questions/33375576/get-applicationdidfinishlaunching-call-in-a-view-controller-parse-not-initializ

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!