EXC_BAD_ACCESS on [error localizedDescription];
This Code trows an EXC_BAD_ACCESS:
NSError* error;
if(![appdelegate.managedObjectContext countForFetchRequest:requ开发者_如何学Pythonest error:&error]) {
DLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
DLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
DLog(@" %@", [error userInfo]);
}
}
Since you don't ask, I assume you want to know what is causing the error in the title. Looks to me like your query returned 0 objects, and you are treating that condition as if it was an error when there was none, and so error was never initialized (it wasn't even allocated) so that's why you're getting a bad access exception
NSError* error = nil;
is correct
This is not really a question. I searched for that and i took me long to find the answer so here it is!
精彩评论