Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use of undeclared identifier 'NSEntityDescription'

I've been banging my head against this for too long. I have two ViewControllers trying to use NSEntityDescription, one can and one can't (giving me the above error).

Both ViewControllers import AppDelegate.h

I figure that it has to be a problem with the ManagedObjectContext but both ViewControllers set the ManagedObjectContext in ViewDidLoad the same way:

if (!self.managedObjectContext) {
        self.managedObjectContext =  [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
    }

Maybe it has to do with the view controller hierarchy? Tho, I'm under the assumption that the use of NSEntityDescription is based upon the managedObjectContext.

Thanks!

like image 844
ari gold Avatar asked Aug 06 '12 17:08

ari gold


1 Answers

I typically add #import <CoreData/CoreData.h> to my Prefix.pch to ensure that it's available to all classes. It sounds like you forgot to import the Core Data headers in one of the view controllers.

like image 155
Mark Adams Avatar answered Sep 17 '22 17:09

Mark Adams