Cannot get IMP from objc block (missing block_getImplementation(NSBlock block))
| Originator: | satsumac | ||
| Number: | rdar://10097262 | Date Originated: | 2011/11/09 |
| Status: | Closed | Resolved: | yes |
| Product: | Mac OS X SDK | Product Version: | |
| Classification: | Enhancement | Reproducible: |
Summary: There should be a way to obtain an IMP from an NSBlock. In an analgous manner as "IMP method_getImplementation(Method method)" (http://developer.apple.com/library/mac/documentation/Cocoa/Reference/ObjCRuntimeRef/Reference/reference.html#//apple_ref/c/func/method_getImplementation). This would allow us to do something like this: "method_setImplementation(myMethod, block_getImplementation(myBlock));" Or in english: Replace implementation of method X with implementation of block Y. This would of course require the block and method to have the same return type as well as the same order and types of arguments (plus self & _cmd). The implementation of a method like "- (BOOL)foo:(Foo *)foo;" could then be replaced with the implementation of a block like "BOOL(^)(id self, SEL _cmd, Foo *)". Notes: Being an Objective-C runtime feature request his also relates to the iOS SDK.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Thanks, found it myself today, by accident. It's still lacking public documentation apparently.
http://www.friday.com/bbum/2011/03/17/ios-4-3-imp_implementationwithblock/