ari gold
ari gold

Reputation: 2094

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!

Upvotes: 13

Views: 7629

Answers (1)

Mark Adams
Mark Adams

Reputation: 30846

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.

Upvotes: 36

Related Questions