日期:2014-05-16 浏览次数:20403 次
如下图:
从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; }