方法に困っていNSFetchedResultsController's
ます。実装を読みましたが、クリックしていないようです。具体的には、これらの方法 (Apple ドキュメントから):
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [[<#Fetched results controller#> sections] count];
}
- (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section];
return [sectionInfo numberOfObjects];
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
id <NSFetchedResultsSectionInfo> sectionInfo = [[<#Fetched results controller#> sections] objectAtIndex:section];
return [sectionInfo name];
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return [<#Fetched results controller#> sectionIndexTitles];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
return [<#Fetched results controller#> sectionForSectionIndexTitle:title atIndex:index];
}
私が理解していないのはsections
とsectionIndexTitles
プロパティです。を初期化するときにこれらのプロパティを宣言したことはありNSFetchedResultsController
ませんが、XCode はどのようにしてそれらを認識し、クラッシュせずに表示するのでしょうか?
さらにその方法では
NSFetchedResultsController *controller = [[NSFetchedResultsController alloc]
initWithFetchRequest:fetchRequest
managedObjectContext:context
sectionNameKeyPath:nil
cacheName:@"<#Cache name#>"];
の設定方法がわかりませんsectionNameKeyPath
。たとえば、完了したタスクと未完了のタスクを含む To Do リストを作成したい場合、それらを 2 つのセクションに区別するにはどうすればよいでしょうか? タスク エンティティに値が必要ですか? そして、この値は文字列である必要がありますか/カスタムセッターを指定する必要がありますか?
助けていただければ幸いです。