您可以检查这样的:/ 房产/
YourClass *arrObj=[YourClass new];//your target class where you wnat to check
NSString *[email protected]"samllArray";//this is what you will check in class YourClass
if([arrObj respondsToSelector:NSSelectorFromString(propertyName)]){
NSLog(@"yes, exists");
}
else{
NSLog(@"no, it does not exists");
}
编辑:/ 为高德/
- (NSMutableArray *)getAllPropertyOfClass:(Class)aClass {
NSMutableArray *mArray=[NSMutableArray new];
unsigned int outCount;
Ivar *ivars = class_copyIvarList([aClass class], &outCount); //class_copyPropertyList([aClass class], &outCount);
for(unsigned int i = 0; i < outCount; i++) {
Ivar ivar = ivars[i];
const char *propName = ivar_getName(ivar);
if(propName) {
NSString *propertyName = [NSString stringWithUTF8String:propName];
mArray[mArray.count]=propertyName;
}
}
free(ivars);
return mArray;
}
http://stackoverflow.com/questions/2299841/objective-c-introspection-reflection。看看第一个答案 – giorashc 2013-04-09 06:14:58
@afsal:你确定你需要伊娃吗?那么像@ property/@ synthesize这样的东西将没有财产? – 2013-04-09 06:24:18
@AnoopVaidya是的。我确定。 例如 长ID; NSString *名字; – 2013-04-09 11:18:05