How to debug core data loss on a sample request

the second time I perform

[[MOC executeFetchRequest:request error:&error] lastObject];

after he said

NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:[NSEntityDescription entityForName:@"Login" inManagedObjectContext:MOC]];
NSError *error = nil;

it crashes with EXC_BAD_ACCESS. The debugging window is turned on, and it seems that the crash is happening deep in the Core Data stack. Any idea on how I should debug this to find out what is going on?

alt text

(just in case, here is the link to the picture http://tinypic.com/r/zmavph/6 Click on the picture in the link and the debug window will increase)

Hurrah

Nik

+3
source share
2 answers

EXC_BAD_ACCESS- memory error. You use the object after it is freed. It would be difficult to debug this without (more) code.

(Xcode > Build > Build and Analyze)?

:

NSArray *fetchedObjects = [MOC executeFetchRequest:request error:&error]
if (!fetchedObjects) {
    NSLog(@"Error fetching Login: %@", [error localizedDescription]);
    abort();
}

NSManagedObject *loginObject = [fetchedObjects lastObject];
+3

Apple CoreData.

+1

Source: https://habr.com/ru/post/1726289/


All Articles