问题
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