且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Swift/iOS:如何将数据从 AppDelegate 传递到 ViewController 标签?

更新时间:2023-02-01 19:21:58

如果是root就可以了

You can do this if it's the root

if let vc = self.window?.rootViewController as? ViewController {
    vc.result.text = u
}

要获得完整的解决方案,您应该使用 获得最***的 UIViewController 获得最***的 vc,然后像上面一样投射

For a complete solution you should get the top most vc with Get top most UIViewController then cast it like above