libextobjc
libextobjc copied to clipboard
Problem in EXTAspect with NSManagedObjects from CoreData
In CoreData entity (child of NSManagedObject) work little bit tricky. Doc says:
NSManagedObject uses dynamic class generation to support the Objective-C 2
properties feature (see “Objective-C 2 Support”) by automatically creating a subclass of
your class appropriate for your entity. This is also typically transparent to you, however
whereas NSManagedObject’s class method returns your class, the Objective-C
function object_getClass returns the dynamically-generated class.
This leads to the fact that in
- (void)adviseSetters:(void (^)(void))body property:(NSString *)property
property == nil
One way to fix it is replace object_getClass(self) with [self class] in
static void setterAdviceMethod (ffi_cif *cif, void *result, void **args, void *userdata)
But I'm not sure about it
Unfortunately, EXTAspect is not really supported code. It was mostly a proof-of-concept, and I really wouldn't recommend using it in production.