你好,我正试图在我的IOS应用程序中实现推送通知功能。目前我有代码,如果通过推送通知打开应用程序,将打开一个特定的视图控制器。我这样做的方式是通过推动viewtopler ontop。如何将数据从appdelegate传递给viewcontroller?
我现在需要做的是将一些数据从appdelegate传递给viewcontroller。我明白从viewcontroller传递数据到viewcontroller是使用prepareforsegue。我试过这样做,但它没有工作
我试图研究如何完成这项任务,但很多在stackoverflow上的答案是过时的swift代码,我没有能力转换为swift 3.有人可以解释对我来说如何将数据从appdelegate发送到视图控制器?
继承人的代码,以显示VC是在didFinishLaunchingWithOptions
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let destinationViewController = storyboard.instantiateViewController(withIdentifier: "detailPin2") as! detailPinViewController
let navigationController = self.window?.rootViewController as! UINavigationController
navigationController.pushViewController(destinationViewController, animated: false)
显示您正在使用的代码*显示AppDelegate中的VC。 – DonMag
编辑帖子。代码现在应该是 – JackieXY
我错过了什么吗?你在appdelegate中有一个函数,你有一个指向你的目标VC的指针。你不能用你打算通过的数据来调用你的VC的成员函数吗? – Spads