Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'NSInternalInconsistencyException', reason: "Foo" is not a subclass of NSManagedObject

Ok so this is the error I'm getting

   *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '"Place" is not a subclass of NSManagedObject.'

I assume that what it means is that 'Place' hasn't been added as an entity to the core data model??? But it has as shown by the image below.

I'm guessing that my assumption is incorrect though so any help or ideas would be nice.

I'm pretty certain that this is the line that's causing it:

  NSManagedObject* place = [NSEntityDescription
                               insertNewObjectForEntityForName:@"Place" 
                               inManagedObjectContext:context];
like image 471
user1135469 Avatar asked May 18 '12 17:05

user1135469


2 Answers

If you aren't using custom classes (no Place.[hm]), as it sounds like you're not, check the Entity tab, and make sure the Class name is blank (= NSManagedObject) – not Place.

like image 128
paulmelnikow Avatar answered Oct 10 '22 02:10

paulmelnikow


I had the same problem with classes called Message and Connection. The error just appeared after adding an emailing facility using the MessageUI library. I believe the conflict occurs because the library will have classes named Message and Connection, therefore they are not seen to be subclasses of NSManagedObject. Changing their names by prefixing (in my case with an X) makes the entities unique. I intend prefixing all my entities in future so that there is less chance of the conflict arising.

like image 21
Alexander Watt Avatar answered Oct 10 '22 03:10

Alexander Watt