Reputation: 8810
the second time I execute
[[MOC executeFetchRequest:request error:&error] lastObject];
after having said
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Login" inManagedObjectContext:MOC]];
NSError *error = nil;
it crashes with a EXC_BAD_ACCESS. Included is the debug window, and it looks like the crash happens deep down in the Core Data stack. Any idea on how I should go about debugging this to find out what's going on?
(just in case, here's the link to the picture http://tinypic.com/r/zmavph/6 Click on the picture in the link and the debug window will get larger)
Cheers
Nik
Upvotes: 3
Views: 4342
Reputation: 21460
EXC_BAD_ACCESS
is a memory error. You are using an object after deallocating it. It would be difficult to debug this without (more) code.
Have you tried running the analyzer (Xcode > Build > Build and Analyze)?
You may also want to break out the fetch and array lookup:
NSArray *fetchedObjects = [MOC executeFetchRequest:request error:&error]
if (!fetchedObjects) {
NSLog(@"Error fetching Login: %@", [error localizedDescription]);
abort();
}
NSManagedObject *loginObject = [fetchedObjects lastObject];
Upvotes: 3