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

fetchedResultsController.fetchObjects is not empty, but [FRC objectAtIndexPath:indexPath] return nil? #81

Open
zenghaojim33 opened this issue Apr 22, 2016 · 6 comments

Comments

@zenghaojim33
Copy link
Contributor

I used this library in my project and it works well on 64bit devices, but this bug happens on iPhone5 and iPhone4s. Basically I just copy codes from the demo project. Any idea what may cause this ? thanks in advance.

@bigfish24
Copy link
Contributor

I have no idea. Can you run demo project directly?

@zenghaojim33
Copy link
Contributor Author

OK I found the solution. In RBQObjectCacheObject.m file

+ (RLMObject *)objectInRealm:(RLMRealm *)realm
              forCacheObject:(RBQObjectCacheObject *)cacheObject
{
    if (cacheObject.primaryKeyType == RLMPropertyTypeString) {

        return [realm objectWithClassName:cacheObject.className forPrimaryKey:cacheObject.primaryKeyStringValue];
    }
    else if (cacheObject.primaryKeyType == RLMPropertyTypeInt) {
        NSNumber *numberFromString = @(cacheObject.primaryKeyStringValue.integerValue);

        return [realm objectWithClassName:cacheObject.className forPrimaryKey:numberFromString];
    }
    else {
        @throw ([self unsupportedPrimaryKeyTypeException]);
    }
}

I change integerValue to LonglongVaue since my primary key number is long long and it's very large so this causes some precision loses.

@bigfish24
Copy link
Contributor

Ah, nice catch!

@bigfish24
Copy link
Contributor

@zenghaojim33 can you submit PR with this change?

@zenghaojim33
Copy link
Contributor Author

Sure.

@tuananh00473
Copy link

tuananh00473 commented Jul 5, 2016

I checked my code in RBQObjectCacheObject.m as longLongValue like here
`+ (RLMObject *)objectInRealm:(RLMRealm *)realm
forCacheObject:(RBQObjectCacheObject *)cacheObject
{
if (cacheObject.primaryKeyType == RLMPropertyTypeString) {

    return [realm objectWithClassName:cacheObject.className forPrimaryKey:cacheObject.primaryKeyStringValue];
}
else if (cacheObject.primaryKeyType == RLMPropertyTypeInt) {
    NSNumber *numberFromString = @(cacheObject.primaryKeyStringValue.longLongValue);

    return [realm objectWithClassName:cacheObject.className forPrimaryKey:numberFromString];
}
else {
    @throw ([self unsupportedPrimaryKeyTypeException]);
}

}`

but i still take this issue. Can you help me!

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

3 participants