标签:
首先我们要知道,这使用的是运行时的反射机制所以我们需要头文件 runtime.h
+(BOOL)checkoutOneTabByName:(NSString*)oneName { //openDB FMDatabase *db = [DatabaseOperation openDataBase]; NSArray *array = [DatabaseOperation queryTable:oneName QueryString:[NSString stringWithFormat:@"select * from %@",oneName] DB:db]; for (id oneData in array) { unsigned int propertyCount =0; objc_property_t *FPAddress =class_copyPropertyList([oneData class], &propertyCount); for (int i =0; i<propertyCount; i++) { objc_property_t *aProp =FPAddress+i; NSString *aName =[NSString stringWithUTF8String:property_getName(*aProp)]; NSObject *aValue =[oneData valueForKey:aName]; NSLog(@"%@,,,%@",aName,aValue); } NSLog(@"( * ^ __ * ^ ) %@ part print success",[oneData class]); } //关闭数据库 [DatabaseOperation closeDataBase:db]; return YES; }
标签:
原文地址:http://blog.csdn.net/u010130947/article/details/42521669