+(BOOL)resolveClassMethod:(SEL)aSel { NSString *lString = NSStringFromSelector(aSel); if ([self validateLetterAndAccidental:lString]) { id (^noteFactoryBLOCK)(id) = ^(id aSelf) { return [self noteWithString:lString]; }; IMP lIMP = imp_implementationWithBlock(noteFactoryBLOCK); ...
I get an error on the last line because noteFactoryBLOCK is passed to void *, and ARC forbids this. Is there a way to do what I want? I need an IMP that I can pass class_addMethod at runtime.
EDIT
IMP myIMP = imp_implementationWithBlock(objc_unretainedPointer(noteFactoryBLOCK));
This line gives me a warning instead of an error - Semantic Issue: Passing 'objc_objectptr_t' (aka 'const void *') to parameter of type 'void *' discards qualifiers
griotspeak
source share