Runtime----運転時

1038 ワード

①.プライベートメンバー変数
+ (void)initialize {
    
    //   runtime               
    //        
    unsigned int count = 0;
   
   //            
    Ivar *ivars = class_copyIvarList([UITextField class], &count);
    
    for (int i = 0; i < count; i++) {
        
        //      
        Ivar ivar = *(ivars + i);
        
        //      
        NSLog(@"%s",ivar_getName(ivar));
    } 
   
    //  
    free(ivars);  
}

②.属性の取得
+ (void)initialize {
    
    //   runtime               
    //        
    unsigned int count = 0;
   
   //        
    objc_property_t *properties = class_copyPropertyList([UITextField class], &count);
    
    //    
    for (int i = 0; i < count; i++) {
        
        //    
        objc_property_t property = properties[i];
        
        //            
        NSLog(@"%s---------%s",property_getName(property),property_getAttributes(property));
    } 
   
    //  
    free(properties);  
}