方法调配对于实例方法非常有用.现在,我需要调整一个类方法.知道怎么做吗?
试过这个,但它不起作用:
void SwizzleClassMethod(Class c, SEL orig, SEL new) {
Method origMethod = class_getClassMethod(c, orig);
Method newMethod = class_getClassMethod(c, new);
if(class_addMethod(c, orig, method_getImplementation(newMethod), method_getTypeEncoding(newMethod)))
class_replaceMethod(c, new, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
else
method_exchangeImplementations(origMethod, newMethod);
}
Run Code Online (Sandbox Code Playgroud) 是否可以获取给定通知名称的观察者(对象和选择器)列表?(NSNotificationCenter)