Subclass of NSManagedObject

I created a subclass of NSManagedObject for my Story model. I am creating several new stories like this:

Story *newStory = [NSEntityDescription insertNewObjectForEntityForName:@"Story" inManagedObjectContext:context];

...

[stories addObject:newStory];

And then later:

Story *story = [stories objectAtIndex:[indexPath indexAtPosition:[indexPath length] - 1]];

However, it turns out that [story class]in essence is NSManagedObject, not Story, and when I try to call the method that I defined in Story, it says unrecognized selector. What am I doing wrong?

+3
source share
1 answer

Make sure you specify the class you want to use for NSManagedObject. You do this in the Xcode data model editor. The Class field is directly below the Name field in the Entity inspector.

+5
source

Source: https://habr.com/ru/post/1774754/


All Articles