Use AppDelegate in today extension

我是研究僧i 提交于 2019-12-19 21:43:06

问题


I'm trying to build an today extension for my app.

I'm using CoreData and NSFetchedResultsController and get the following error:

Use of undeclared type 'AppDelegate'

In this line of code:

var appDel: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate. 

Does someone know how to solve this error / use AppDelegate in the today extension and would like to help me?


回答1:


A Today Extension isn't an application, so UIApplication and AppDelegate aren't available. I'm not for sure what you are trying to do with the AppDelegate, but extensions do have a NSExtensionContext available by calling:

 self.extensionContext


来源:https://stackoverflow.com/questions/29720440/use-appdelegate-in-today-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!