Dav*_*ong 13 cocoa objective-c objective-c-runtime
如何获取特定类的类方法列表?我已经尝试使用class_copyMethodList声明的函数<objc/runtime.h>,但这只是给我实例方法.我还找到了一个函数,它给了我一个类方法的方法,但前提是我有方法的选择器first(class_getClassMethod).
有任何想法吗?
谢谢,
戴夫
小智 21
使用元类.
#import <objc/runtime.h>
int unsigned numMethods;
Method *methods = class_copyMethodList(objc_getMetaClass("NSArray"), &numMethods);
for (int i = 0; i < numMethods; i++) {
NSLog(@"%@", NSStringFromSelector(method_getName(methods[i])));
}
free(methods);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5548 次 |
| 最近记录: |