Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash with the following json #84

Open
xujiajia opened this issue May 10, 2016 · 1 comment
Open

crash with the following json #84

xujiajia opened this issue May 10, 2016 · 1 comment

Comments

@xujiajia
Copy link

xujiajia commented May 10, 2016

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 ...

@viktorasl
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants