Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ios类\u copyPropertyList返回较少的计数属性_Ios_Objective C_Runtime - Fatal编程技术网

ios类\u copyPropertyList返回较少的计数属性

ios类\u copyPropertyList返回较少的计数属性,ios,objective-c,runtime,Ios,Objective C,Runtime,我在函数中调用类\ uCopyPropertyList + (NSDictionary *)classPropsFor:(Class)klass{ if (klass == NULL) { return nil; } NSMutableDictionary *results = [[NSMutableDictionary alloc] init] ; unsigned int outCount, i; objc_property_t *

我在函数中调用类\ uCopyPropertyList

+ (NSDictionary *)classPropsFor:(Class)klass{
    if (klass == NULL) {
        return nil;
    }

    NSMutableDictionary *results = [[NSMutableDictionary alloc] init] ;

    unsigned int outCount, i;
    objc_property_t *properties = class_copyPropertyList(klass, &outCount);
    for (i = 0; i < outCount; i++) {
        objc_property_t property = properties[i];
        const char *propName = property_getName(property);
        if(propName) {
            const char *propType = getPropertyType(property);
            NSString *propertyName = [NSString stringWithUTF8String:propName];
            NSString *propertyType = [NSString stringWithUTF8String:propType];
            if (propertyType != nil){
                [results setObject:propertyType forKey:propertyName];
            }
        }
    }
    free(properties);

    // returning a copy here to make sure the dictionary is immutable
    return [NSDictionary dictionaryWithDictionary:results];
}
但以具有2个属性的类为例,它会获得不同的属性计数列表:一次0计数,另一次2计数,另一次1计数

为什么?


这发生在iOS 7上

可能是因为:问题是运行时返回NSNumber