0

We are using Swift and we made a "UITableViewController" inside our project folder. We are trying to access our "AppDelegate" functions. We have tried using

    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate 

We have also tried

    let appDelegate = UIApplication.sharedApplication()

Any ideas why this is not working?

We also have

    let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

inside our "ViewController" and it works there.

The error is " Use of undeclared Type 'AppDelegate' "

Vishnu Murale
  • 173
  • 14
  • What "isn't working?" Are you getting a syntax error? – JAL Dec 03 '15 at 16:20
  • What are you trying to accomplish? Maybe it can be done another way. Have you tried making those functions public? 'public func ...'? Can you not access the App Delegate or the functions inside? – Lukesivi Dec 03 '15 at 16:24

1 Answers1

0

Change that line to

let appDelegate = (UIApplication.sharedApplication().delegate as! AppDelegate).managedObjectContext
Dimuth
  • 713
  • 2
  • 11
  • 34
Niall Kehoe
  • 416
  • 5
  • 17
  • Please elaborate on how this answers the question. I don't see any information about Core Data in the question. – JAL Dec 03 '15 at 18:31
  • @JAL I don't know the answer, but I think it's here http://stackoverflow.com/questions/33521401/uiapplication-sharedapplication-delegate-as-appdelegate-managedobjectcontext – Niall Kehoe Dec 04 '15 at 15:56
  • This has nothing to do with Core Data or `NSManagedObjectContext`. In addition, if you feel that this question is a duplicate, you should flag it as such. – JAL Dec 04 '15 at 16:03
  • If you've the answer, please post it. – Niall Kehoe Dec 04 '15 at 16:38