0
이 link을 보았습니다. 여기서 countforfetch는 항상 1이지만 솔루션을 제공하지 않습니다.핵심 데이터 - 빈 데이터베이스에 대해 항상 countforfetch가 1을 반환합니다.
링크에서 주어진대로 가져 오기 요청을하면 매번 저장하려고했던 데이터가 나타납니다. 그래서 그것의 이미 존재하기 때문에 다시 저장하지 않을 것이다. 그래서 데이터베이스는 비어 있습니다. 그러나 놀랍게도 데이터는 테이블에 있습니다.
이것은 매우 이상한 행동처럼 보입니다. 제발 좀 도와 줄래? 당신은 당신이 MOC에했지만 아직 저장하지 않은 변경 사항을 무시하도록 요청을 인출하려는 경우
여기 내 코드
NSFetchRequest *fetchRequest12 = [[NSFetchRequest alloc] init];
NSError *error;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"orderNumber = %@",orderList.orderNumber];
[fetchRequest12 setPredicate:predicate];
[fetchRequest12 setEntity:[NSEntityDescription entityForName:@"OrderList" inManagedObjectContext:appDelegate.managedObjectContext]];
NSLog(@"The fetch was successful! %@", [appDelegate.managedObjectContext executeFetchRequest:fetchRequest12 error:&error]);
if ([appDelegate.managedObjectContext countForFetchRequest:fetchRequest12 error:&error] ==0) { // Somethings to be done
}
설명 주셔서 감사합니다 .-) –