Unexpected behaviour for isKindOfClass: on NSManagedSubclasses created by mogenerator

52 views Asked by At

I have an entity in my object model called Book whose class attribute is XYZBook. Mogenerator creates 2 classes:

  • _XYZBook
  • XYZBook, which inherits from _XYZBook.

So far so good.

If I create an instance on XYZBook:

XYZBook *b = [XYZBook insertInManagedObjectContext:context];

Sending class to b, returns XYZBook as expected.

[b class] --> XYZBook

However, sending isMemberOfClass:[XYZBook class] returns NO!!!

[b isMemberOfClass:[XYZBook class]] --> NO

It only returns YES if I use the _XYZBook super class:

[b isMemberOfClass:[_XYZBook class]] --> YES

So, what on Earth is going on????

BTW, I create these clases using a custom base class (with the --base-class option for mogenerator). Just in case it has anything to do with this...

0

There are 0 answers