私はcar:NSObject
のようなモデルを持っていますが、それはname
、color
のようなプロパティを持っています。
今私はNSString *[email protected]"name";
を持っていますが、私はこのように使うことができます[car str]
? それは可能ですか?iOSのクラスプロパティ
私が試した:
objc_property_t *properties = class_copyPropertyList([_model class], &propertyCount);
for (unsigned int i = 0; i < propertyCount; ++i) {
objc_property_t property = properties[i];
const char * Cname = property_getName(property);
NSString *name = [NSString stringWithCString:Cname encoding:NSUTF8StringEncoding];
}
をそれはあなたが必ずしもObjective-Cランタイムに直接飛び込む必要はありません
おかげで、 。 –