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

[cache setValue:value forKey:[propertyClass primaryKey]] value 为 nil 崩溃问题 #35

Open
levicc opened this issue Aug 11, 2018 · 0 comments

Comments

@levicc
Copy link

levicc commented Aug 11, 2018

NSDate *date = [NSDate date];
    Employee *employee = [[Employee alloc] initWithId:2
                                                 name:@"New Emp2"
                                          dateOfBirth:date
                                           department:nil];
    [employee save];

像例子那样,存的 department 为 nil,之后取出来会在 300 行处崩溃:

//GYDBRunner.m
if (propertyClass && value) {   //这边加个判断才行
        id cache = [_cacheDelegate objectOfClass:propertyClass id:value];
        if (!cache) {
            cache = [[(Class)propertyClass alloc] init];
            **[cache setValue:value forKey:[propertyClass primaryKey]];**
            [cache setValue:@YES forKey:@"fault"];
            [_cacheDelegate cacheObject:cache];
        }
        value = cache;
    }

按理说肯定会考虑过这个问题,是我的姿势有问题吗?

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

1 participant