Runtime

来源:互联网 发布:淘宝卖家自动核对地址 编辑:程序博客网 时间:2024/04/30 19:14

    // 获取属性列表

//    unsigned int count;

//    objc_property_t *propertyList = class_copyPropertyList([self class], &count);

//    for (unsigned int i =0 ; i< count; i++) {

//        const char * propertyNmae = property_getName(propertyList[i]);

//        

//         NSLog(@"%s",propertyNmae);

//    }

    

    //获取方法列表

//    Method *methodList = class_copyMethodList([self class], &count);

//    

//    for (unsigned int i = 0; i<count; i++) {

//      Method method = methodList[i];

//        NSLog(@"%@",NSStringFromSelector(method_getName(method)));

//    }

   

    // 获取成员变量

//    Ivar *Ivarlist = class_copyIvarList([self class], &count);

//    for ( unsigned int i = 0; i<count; i++) {

//        Ivar myvar = Ivarlist[i];

//        const char * var = ivar_getName(myvar);

//        NSLog(@"%s",ivar_getName(myvar));

//    }

    

    // 获取协议列表

//    __unsafe_unretained Protocol * *protocolList = class_copyProtocolList([self class], &count);

//    for (unsigned int i = 0; i<count; i++) {

//        Protocol *protocol = protocolList[i];

//        NSLog(@"%s",protocol_getName(protocol));

//    }


otocol_getName(protocol));

 关联

//    UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"收拾" message:@"s" delegate:self cancelButtonTitle:@"sure" otherButtonTitles:@"cancel", nil];

//    objc_setAssociatedObject(alert, &ex,

//        @"我是被挂载的",

//        OBJC_ASSOCIATION_RETAIN_NONATOMIC);

//    [alert show];

//- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex

//{

//    if (buttonIndex == 1) {

//        NSLog(@"%@", objc_getAssociatedObject(alertView, &ex));

//    }

//}



0 0
原创粉丝点击