如果是动态库,请确保是已经加载load后HOOK
SEL sel = sel_getUid("codeDiagnosticsAtLocation:withCurrentFileContentDictionary:forIndex:");
Class IDEIndexClangQueryProviderClass = NSClassFromString(@"IDEIndexClangQueryProvider");
Method method = class_getInstanceMethod(IDEIndexClangQueryProviderClass, sel);
IMP originalImp = method_getImplementation(method);
IMP imp = imp_implementationWithBlock(^id(id me, id loc, id dict, IDEIndex idx) {
id ret = ((id ()(id,SEL,id,id,id))originalImp)(me, sel, loc, dict, idx);
return ret;
});
method_setImplementation(method, imp);
网友评论