How to dynamically replace a method implement in ObjC2?

Posted by Abhi on Stack Overflow See other posts from Stack Overflow or by Abhi
Published on 2010-04-07T19:50:38Z Indexed on 2010/04/07 19:53 UTC
Read the original article Hit count: 291

Filed under:
|

I am trying to learn how to write plugins using SIMBL. I got my plugin to load with the target application, and also know the method that I wish to override. However, I am not able to use class_getInstanceMethod correctly based on snippets on the Internet. Have things changed in OSX 10.6 and/or ObjC2?

The following code from culater.net gives "Dereferencing pointer to incomplete type":

BOOL DTRenameSelector(Class _class, SEL _oldSelector, SEL _newSelector)
{
    Method method = nil;

    // First, look for the methods
    method = class_getInstanceMethod(_class, _oldSelector);
    if (method == nil)
        return NO;

    method->method_name = _newSelector;
    return YES;
}

Is there a complete example of how to override a method using SIMBL plugins? Thanks!

© Stack Overflow or respective owner

Related posts about cocoa

Related posts about objective-c