I have two different objects which I create using insertNewObjectForEntityForName using the same context.
My problem is that for the first object, Event, the object type is correctly defined as Event, while for the second object which should be of type Credit, the object type is instead NSManagedObject (which means I can’t called methods defined in the derived class on it).
Object 1: (as expected)
Event *event = (Event*)[NSEntityDescription insertNewObjectForEntityForName:@"Event" inManagedObjectContext:context];
(gdb) po event
<Event: 0x62b3f00> (entity: Event; id: 0x62b3fb0 <x-coredata:///Event/tD3B27884-D303-4FDE-9D0F-D7DC009E2EBB18> ; data: {
...
})
Object 2: (expected class to be Credit and not NSManagedObject)
Credit *credit = (Credit*)[NSEntityDescription insertNewObjectForEntityForName:@"Credit" inManagedObjectContext:context];
(gdb) po credit
<NSManagedObject: 0x629fd50> (entity: Credit; id: 0x628caf0 <x-coredata:///Credit/tD3B27884-D303-4FDE-9D0F-D7DC009E2EBB36> ; data: {
...
})
Presumably you’ve double-checked that the entity is indeed mapped to the
Creditclass in the model editor?