I made a subclass of NSManagedObject for my Story model. I create several new stories like so:
Story *newStory = [NSEntityDescription insertNewObjectForEntityForName:@"Story" inManagedObjectContext:context];
...
[stories addObject:newStory];
And then later on:
Story *story = [stories objectAtIndex:[indexPath indexAtPosition:[indexPath length] - 1]];
However, it turns out that [story class] is actually NSManagedObject, not Story, for some reason, and when I try to call a method that I defined on Story, it says unrecognized selector. What am I doing wrong?
Make sure you specify the class that you want to use for your NSManagedObject. You do this in Xcode's data model editor. The "Class" field is right below the "Name" field in the Entity inspector.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With