Open xujiajia opened 8 years ago
json
{ "list": [ { "liveid": "23", "name": "CCTV1", "catid": "1", "currentlive": { "id": "227670", "channelid": "23" }, "nextlive": { "id": "227671", "channelid": "23" } }, { "liveid": "73", "name": "cctv1-2m", "catid": "1", "currentlive": "", "nextlive": "" } ] }
Model:LiveChannelList
@interface LiveChannelList : RLMObject @property NSString * catid; @property LiveChannelInfo * currentlive; @property NSString * liveid; @property NSString * name; @property LiveChannelInfo * nextlive; @end RLM_ARRAY_TYPE(LiveChannelList) @implementation LiveChannelList +(NSString *)primaryKey{ return @"liveid"; } + (NSDictionary *)JSONInboundMappingDictionary { return @{ @"liveid": @"liveid", @"name": @"name", @"catid": @"catid", @"currentlive": @"currentlive", @"nextlive": @"nextlive" }; } @end
Model:LiveChannelInfo
@interface LiveChannelInfo : RLMObject @property NSString * idField; @property NSString * channelname; @end @implementation LiveChannelInfo + (NSDictionary *)JSONInboundMappingDictionary { return @{ @"id": @"idField", @"channelid": @"channelid" }; } @end
crash ,because the second data in json , currentlive and nextlive ,their valus is "" I try to resolve ,but ...
Hey. It's not quite a valid logic that currentlive and nextlive might carry either object or empty string. Making it a nil as a default value should solve your problem.
currentlive
nextlive
nil
json
Model:LiveChannelList
Model:LiveChannelInfo
crash ,because the second data in json , currentlive and nextlive ,their valus is "" I try to resolve ,but ...