MJ哥 这种模型怎么转化
{ "list":[ { "address":"xxxxx", "contactName":"汪天顺", "userId":1, "open":1, "sections":[ { "siteId":1, "timeInfo":"08:00-09:00" }, { "siteId":1, "timeInfo":"09:00-10:00" }, { "siteId":1, "timeInfo":"10:00-11:00" }, { "siteId":1, "timeInfo":"11:00-12:00" } ] }, { "address":"xxxxx", "contactName":"汪天顺", "userId":2, "open":1, "sections":[ { "siteId":2, "timeInfo":"08:00-09:00" }, { "siteId":1, "timeInfo":"09:00-10:00" }, { "siteId":1, "timeInfo":"10:00-11:00" }, { "siteId":1, "timeInfo":"11:00-12:00" } ] } ] }
可以考虑设计2个模型: 1.拥有address、contactName、userId、open、sections属性 2.拥有siteId、timeInfo模型 其他的你自己斟酌一下了哈,加油
model我知道 但是直接转换不了我想要的结果! @interface UserModel : NSObject @property (nonatomic, copy) NSString *userId; @property (nonatomic, copy) NSString *open; @property (nonatomic, copy) NSString *address; @property (nonatomic, copy) NSString *contactName; @property (nonatomic, retain) NSMutableArray *sections; @end @interface sectionsModel : NSObject @property (nonatomic, copy) NSString *siteId; @property (nonatomic, copy) NSString *timeInfo; @end NSArray *userArray = [UserModel objectArrayWithKeyValuesArray:dictArray]; 这样得到的 userArray里面的 数据是一个 userModel对象 但是 这个对象的sections里面 还是原始的dictionary结构的数组 并没有变成一个 存放 sectionsMode对象的数组? 我的意思就是为什么这样直接转换不了?而不是问你怎么建model
这个? 而且 楼上cher 那个 这话说的 怎么看都不是在请教问题
@cherishloveyou @xlePE 希望你们好好看看github的README哈,里面说得很详细模型数组属性