내가의NSFetchedResultsController : 문서의 설명 내가 문서에서 알 수있는 바와 같이
The fetch request must have at least one sort descriptor. If the controller generates sections, the first sort descriptor in the array is used to group the objects into sections; its key must either be the same as sectionNameKeyPath or the relative ordering using its key must match that using sectionNameKeyPath.
나는 다음과 같은 방법
[[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
managedObjectContext:mainContext
sectionNameKeyPath:@"paymentDate"
cacheName:nil];
섹션으로 NSFetchedResultsController
를 사용하고 애플의 문서에서 몇 가지 해명을해야 할 필요 NSFetchRequest
NSFetchedResultsController
에 적어도 하나의 정렬 설명자가 있어야합니다. 내가 섹션을 사용하기 때문에 그러나, 정렬 설명처럼해야 다음
[fetchRequest setSortDescriptors:[NSArray arrayWithObjects:
[NSSortDescriptor sortDescriptorWithKey:@"paymentDate" ascending:YES],
[NSSortDescriptor sortDescriptorWithKey:@"paymentCode" ascending:YES],
nil]];
나는 다음과 같은
NSFetchedResultsController ERROR: The fetched object at index X has an out of order section name Y. Objects must be sorted by section name'
에서 같은 오류가 발생
[fetchRequest setSortDescriptors:[NSArray arrayWithObjects:
[NSSortDescriptor sortDescriptorWithKey:@"paymentCode" ascending:YES],
nil]];
처럼 정렬이 디스크립터를 사용하는 경우 내 경우
[NSSortDescriptor sortDescriptorWithKey:@"paymentDate" ascending:YES]
을 사용하면이 문제를 극복 할 수 있습니다. 아마 나는 운이 좋다;).
그러나 을 의미하거나 키를 사용하는 상대적인 순서는 sectionNameKeyPath을 사용하는 것과 일치해야합니다. 설명을 해 주시겠습니까?
미리 감사드립니다.
+1입니다. "당신은 정확한 필드를 지정할 필요는 없지만 정렬 순서는 동일해야합니다."라는 것이 무엇을 의미 하는지를 지정할 수 있습니까? 약간의 샘플이 유용 할 수 있습니다 ;-) 감사합니다. –
고마워요 조디. 당신은 핵심 데이터에 대해 잘 알고 있습니다. 건배. –