2011-10-27 1 views
0

나는 임시 개체 titleFirstLetter임시 속성 및 FetchRequest?

및이 특성을 섹션 이름으로 사용하려고하지만 실행할 때 :

 // Create the sort descriptors array. 
NSSortDescriptor *authorDescriptor = [[NSSortDescriptor alloc] initWithKey:@"titleFirstLetter" ascending:YES]; 
NSSortDescriptor *titleDescriptor = [[NSSortDescriptor alloc] initWithKey:@"title" ascending:YES]; 
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:authorDescriptor, titleDescriptor, nil]; 
[fetchRequest setSortDescriptors:sortDescriptors]; 

// Create and initialize the fetch results controller. 
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:@"titleFirstLetter" cacheName:nil]; 
self.fetchedResultsController = aFetchedResultsController; 
fetchedResultsController.delegate = self; 

이 오류가 발생합니다 :

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', 
reason: 'keypath titleFirstLetter not found in entity <NSSQLEntity Book id=1>' 

도와주세요!

+0

http://stackoverflow.com/a/3553471에서보세요. – malaba

답변

0

섹션 색인을 원하고 섹션 헤더가 필요없는 경우 title 속성을 전달하면 원하는 정보를 얻을 수 있습니다.

sectionNameKeyPath:@"title" 

그렇지 않으면, 당신은 실제로 단지 첫 글자를이 섹션 헤더를 원하는 경우, 전체 토론 this previous question를 참조하십시오.