Pixman
Pixman

Reputation: 599

NSFetchRequest cause SIGABRT OR EXC_BAD_ACCESS

I'm using this simple code for my fetch request

NSArray *fetchResults = [moc executeFetchRequest:request error:&error];

NSLog(@" i want show my result : %@",fetchResults); -> cause SIGABRT

If i'm using on my persistent store just after this creation, i have an error.

PS: the store was save between the populate and the request.

But if i close the app, and reopen ( in this case the store exist), i have no error.

in some case i can view this message : terminate called after throwing an instance of 'NSException'

but i can't access to this exception.

if i count the fetch results, i have a good number, it's really strange.

Thanks for help.

Upvotes: 1

Views: 1180

Answers (1)

Pixman
Pixman

Reputation: 599

Okay, I have found the problem!

In the populate code, one of my relationships was insert with an autorelease.

Remove this, and now it's OK.

This is not a good solution:

 NSManagedObject *relationEntity = [[NSEntityDescription insertNewObjectForEntityForName:@"picture" inManagedObjectContext:moc] autorelease];

Simply remove autorelease:

NSManagedObject *relationEntity = [NSEntityDescription insertNewObjectForEntityForName:@"picture" inManagedObjectContext:moc];

I have forgotten this in core data (don't use release, just set object to nil)!

Upvotes: 1

Related Questions