美文网首页
runtime method方法

runtime method方法

作者: d5cbd4f07363 | 来源:发表于2017-08-29 15:50 被阅读13次

    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<count;i++){

    Method method = classMethod[i];

    SEL methodName = method_getName(method);

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

    }

    添加方法:

    相关文章

      网友评论

          本文标题:runtime method方法

          本文链接:https://www.haomeiwen.com/subject/engodxtx.html