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