草庐IT

WKExtension

全部标签

objective-c - WatchKit 中 UIApplication.sharedApplication().delegate 的等价物是什么?

在iOS应用程序中,您可以通过以下方式获取对共享应用程序委托(delegate)的引用:swift:letdelegate=UIApplication.sharedApplication().delegateas!AppDelegateObjective-C:AppDelegate*delegate=[[UIApplicationsharedApplication]delegate];在WatchKit2AppExtension中有一个类似的AppDelegate,我想在ViewController中获取对它的引用以访问应用程序中的共享资源,例如核心数据堆栈的ManagedObject