I'm working on a Core Data application where my entities have a common property called deleted
(I'm implementing logical deletion in the app).
While all the entities could inherit from a common one, I would like to avoid it (I don't like how when using inheritance all the entities end up in the same table, but I digress).
In order to keep the code tidy, I implemented a protocol as such:
@protocol SPRLogicalDeleteEntity <NSObject>
@property (nonatomic, retain) NSNumber * deleted;
@end
and I want all the NSManagedObject
subclasses to conform to this protocol, so the code looks better. In order for the code to be maintainable, I don't want to add the protocol to the generated NSManagedObject
subclasses, so instead, I created a class extension:
@interface Product () < SPRLogicalDeleteEntity >
@end
that I use only to mark the entity as conforming to my protocol.
The problem I'm having is that calls to conformsToProtocol:@protocol(SPRLogicalDeleteEntity)
return NO
.
I haven't tried mogenerator (but I could if strictly required). Any tip? Could this be because the class extension is empty and thus not loading?