我正在尝试用以下代码替换方法实现
BOOL ct_hookMethod(Class originalClass, SEL originalSelector, Class swizzledClass, SEL swizzledSelector)
{
Method originalMethod = class_getInstanceMethod(originalClass, originalSelector);
Method swizzledMethod = class_getInstanceMethod(swizzledClass, swizzledSelector);
if (originalMethod && swizzledMethod)
{
method_exchangeImplementations(originalMethod, swizzledMethod);
return YES;
}
return NO;
}
它适用于-[xxxView runRequest:]
之类的选择器,但不适用于-[xxView runRequest:]_block_invoke:
之类的方法。
有人知道如何钩住他们吗?