On Aug 20, 2008, at 4:21 AM, Antonio Nunes wrote:
I don't know how this would scale to 'super'. I don't think you can pass in a pointer to super, as that is not how the mechanism works. While "self" is a variable name "super" is a flag to the compiler telling it where to begin searching for the method to perform. That wouldn't work outside of the object's context like in a C function. You would have to find a way access the superclass's methods within the callback function. I suppose it would involve calling objc_msgSendSuper or objc_msgSendSuper_stret directly, but that is unknown territory to me. I'd be interested myself in how that is done if anyone is willing to supply the answer.
Well, you can try to achieve this result with the Objective-C runtime. The better approach would be to have the C function be a very simple wrapper around an Objective-C method (as you illustrated) and then have that method invoke 'super' if necessary.
If you really wanted to do it directly, you could grab the implementation for the method, a function pointer, and call through that:
Class theSuperClass = [anObject superclass]; SEL theSelector = @selector(someMethod); if ([theSuperClass instancesRespondToSelector:theSelector]) { IMP f = [theSuperClass instanceMethodForSelector:theSelector]; f(anObject, theSelector); } Cheers, Ken _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]