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 -com.apple.CoreData.ConcurrencyDebug 1 when fetching entites #950
Comments
Thats because you are fetching in background without specifying a context. NSManagedObjectContext *context = [NSManagedObjectContext MR_context];
[context performBlock:^{
PSPlayer *player = [[PSPlayer MR_findAllInContext:context] firstObject];
NSLog(@"player = %@", player.name);
}]; |
ok, I see. I thought that all the methods described in the docs were guaranteeing to use the appropriate context. Also, I have to surround the access with |
Now, how come I have the crash when calling this in a - (void)main
{
@autoreleasepool {
NSManagedObjectContext *context = [NSManagedObjectContext MR_context];
PSPlayer *player = (PSPlayer *) [context objectWithID:self.playerId];
NSLog(@"name = %@", player.name);
// rest of NSOperation logic
}
} Do I have to wrap the entire logic of the NSOperation in - (void)main
{
@autoreleasepool {
__block BOOL keepUpdating = YES;
__block PSPlayer *player;
NSManagedObjectContext *context = [NSManagedObjectContext MR_context];
[context performBlockAndWait:^{
player = (PSPlayer *) [context objectWithID:self.playerId];
NSLog(@"name = %@", player.name);
// rest of NSOperation logic
}];
}
} |
|
ok thanks. objc.io is my Bible but it looks like I should read it more often. cheers |
Hi,
every time I fetch and access a
NSManagedObject
in a background thread with-com.apple.CoreData.ConcurrencyDebug 1
, I get a crash. It is reproducible with:I'm using
2.3.0 beta 5
The text was updated successfully, but these errors were encountered: