Get applicationDidFinishLaunching call in a View C

2019-09-11 08:21发布

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条回答
Lonely孤独者°
2楼-- · 2019-09-11 09:04

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
}
查看更多
登录 后发表回答