在视图控制器中获取 applicationDidFinishLaunching 调用.解析尚未初始化 [英] Get applicationDidFinishLaunching call in a View Controller. Parse not initialized yet

查看:22
本文介绍了在视图控制器中获取 applicationDidFinishLaunching 调用.解析尚未初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我的 Initial View Controller 中的 Parse 加载数据.问题是 Parse 是在我的 AppDelegatedidFinishLaunching 中初始化的,所以我需要等到它被调用,然后才能尝试从 Parse 加载数据.在我的视图控制器中获取此通知的最佳方法是什么?或者在我的 AppDelegate 中获取数据会更好吗?

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?

感谢所有帮助!

推荐答案

您可以在视图控制器 viewDidLoad 方法中为 UIApplicationDidFinishLaunchingNotification 添加观察者:

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

NotificationCenter.default.addObserver(self, selector: #selector(didFinishLaunchingNotification), name: UIApplication.didFinishLaunchingNotification, object: nil)

将您的方法添加到视图控制器

Add your method to the view controller

@objc func didFinishLaunchingNotification(_ notification: Notification) {
    // your code
}

这篇关于在视图控制器中获取 applicationDidFinishLaunching 调用.解析尚未初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆