Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use AppDelegate in today extension

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?

like image 347
horst Avatar asked Nov 01 '22 06:11

horst


1 Answers

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
like image 96
duncanc4 Avatar answered Nov 15 '22 05:11

duncanc4