magicalpanda / MagicalRecord

Super Awesome Easy Fetching for Core Data!
Other
10.8k stars 1.79k forks source link

MR returns object and after that twice releasing occurred. #1183

Closed ghost closed 8 years ago

ghost commented 8 years ago

I save token with next method

- (void)newsSource:(id <LRNewsSource>)source didReceiveNewPageToken:(NSString *)token
{
    [MagicalRecord saveWithBlock:^(NSManagedObjectContext * _Nonnull localContext) {
        LRNewsSourcePagination *pageToken = [LRNewsSourcePagination MR_findFirstOrCreateByAttribute:@"newsSourceType"
                                                                                          withValue:@(source.type)
                                                                                          inContext:localContext];

        pageToken.newPageToken = token;
    }];
}

after relaunch get value like this

- (LRNewsSourcePagination *)newsSourceDidRequestPageToken:(id <LRNewsSource>)source
{
    LRNewsSourcePagination *pageToken = [LRNewsSourcePagination MR_findFirstByAttribute:@"newsSourceType"
                                                                              withValue:@(source.type)];

    return pageToken; 
}

Result - first time when value read from DB all work normally, but when next time app want to read value from instance - instance var become zombie object. So strange. All properties which store a value are strong. Need some advice or help.

screen from zombie inspector https://www.dropbox.com/s/p9pk4gidqq0b9q4/Screenshot%202016-02-03%2017.45.26.png?dl=0