0
私は次のようにのUITableViewのセクションのセクションを移入しています:?fetchedResultsController.sectionsからオブジェクトを取得[セクション]
fetchedResultsController =
NSFetchedResultsController(fetchRequest: fetchRequest,
managedObjectContext: managedContext,
sectionNameKeyPath: #keyPath(Players.team),
cacheName: nil)
私のUITableViewはセクションにteam
を持っています。私はまた、セクションに市を追加したいと思います。私はセクションに2つの項目を追加できるとは思わない。次のデータが必要なデータがあることがわかります。しかし、私はどのように都市の情報を取得するのですか?
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
let sectionInfo = fetchedResultsController.sections?[section]
print("sectionInfo \(String(describing: sectionInfo?.objects))")
return sectionInfo?.name
}
結果:
sectionInfo Optional([<Time_on_Ice.Players: 0x1c028cf30> (entity: Players; id: 0xd000000000100000 <x-coredata://EE1C8D6B-3FC5-4460-9F7F-3830328B6688/Players/p4> ; data: {
birthdate = "1990-02-07 05:00:00 +0000";
city = "Tampa Bay";
division = Atlantic;
firstName = Steven;
headshot = <ffd8ffe0 00104a46 49460001 01000048 00480000 ffe10058 45786966 00004d4d 002a0000 00080002 01120003 00000001 0001>;
height = "5'11\"";
lastName = Stamkos;
league = NHL;
level = Professional;
number = 91;
playersShiftRelationship = "<relationship fault: 0x1c403d060 'playersShiftRelationship'>";
position = Centre;
shoots = Right;
team = Lightning;
weight = "177 lb";
})])