runtime method方法

runtime method方法_第1张图片
runtime method方法_第2张图片

Person * pp = [Person new];

Class class = object_getClass(pp);//获取类对象的class

Class metaC = objc_getMetaClass(class_getName(class));

if (class_isMetaClass(metaC)) {//如果是元类对象

unsigned int count;

Method * classMethod = class_copyMethodList(metaC, &count);

for (unsigned int i = 0; i

Method method = classMethod[i];

SEL methodName = method_getName(method);

NSLog(@"类方法:%@",NSStringFromSelector(methodName));

}

添加方法:


runtime method方法_第3张图片

你可能感兴趣的:(runtime method方法)