How to dynamically replace a method implementation 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
20:23 UTC
Read the original article
Hit count: 322
cocoa
|objective-c
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" on the second-last statement:
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