0
我正在使用下面的代码,并且在获取对象的计数时收到EXC_BAD_ACCESS - 任何人都有任何想法为什么?奇怪的是,错误只发生在计数应该是1或更大的情况下,如果没有对象它似乎工作正常(它输出为空)。核心数据问题 - EXC_BAD_ACCESS
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"TVShow" inManagedObjectContext:[self managedObjectContext]];
[fetchRequest setEntity:entity];
[fetchRequest includesPendingChanges];
//NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ID == %@", showId];
//[fetchRequest setPredicate:predicate];
NSError *error;
NSLog(@"Generating Count");
NSUInteger count = [[self managedObjectContext] countForFetchRequest:fetchRequest error:&error];
if(count == NSNotFound) {
NSLog(@"error");
}
else {
NSLog(@"%@", count); // EXC_BAD_ACCESS here
}
[fetchRequest release];
Ahh Ha!谢谢! – BarrettJ 2010-05-04 19:39:31
从同一个问题中拯救了我。谢谢! – mariusnn 2012-08-29 10:00:51