标签:ios nsdictionary 遍历属性
如下图:
从user_logs表格select出来的数据放在一个可变数组NSMutableArray中,如 user_logs,现在要
把数据一条条转化为Userlog databean,UserLog定义如下:@interface UserLog : NSObject @property(strong,nonatomic) NSString * logId; @property(strong,nonatomic) NSString * userId; @property(strong,nonatomic) NSString * actionType; @property(strong,nonatomic) NSDate * actionDate; @property(strong,nonatomic) NSString * accountNumber; @property(strong,nonatomic) NSString * dataRef1; @property(strong,nonatomic) NSString * dataRef2; @property(strong,nonatomic) NSString * dataRef3; @property(nonatomic) BOOL uploaded; @property(nonatomic) NSInteger udts; @property(strong,nonatomic) NSString * logType; - (NSDictionary *)convertToDictionary; @end
-(NSDictionary *)convertUserLogsPropertyToDictionary:(NSMutableArray *)userLogs{ NSMutableArray *userLogsMutableArray = [NSMutableArray array]; for (int i = 0;i< [userLogs count];i++) { UserLog *userLog = userLogs[i]; [userLogsMutableArray addObject:[userLog convertToDictionary]]; } NSDictionary *userLogsDictionary = @{@"objects":userLogsMutableArray}; return userLogsDictionary; }
将数据库select出来的数据转化为与相应databean对应的字典,布布扣,bubuko.com
将数据库select出来的数据转化为与相应databean对应的字典
标签:ios nsdictionary 遍历属性
原文地址:http://blog.csdn.net/chaoyuan899/article/details/25308325