До Swift 4.2 я мог бы создать заголовок NSCollectionView
следующим образом:
func collectionView(_ collectionView: NSCollectionView, viewForSupplementaryElementOfKind kind: NSCollectionView.SupplementaryElementKind, at indexPath: IndexPath) -> NSView {
let view = collectionView.makeSupplementaryView(ofKind: .sectionHeader, withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Header"), for: indexPath as IndexPath) as! Header
view.sectionTitle.stringValue = collectionSections[indexPath.section]
return view
}
Если я правильно помню, .sectionHeader
был из enum
изNSCollectionView.SupplementaryElementKind
.Но документы говорят NSCollectionView.SupplementaryElementKind
это String
.
Это оставляет меня с обновленным Swift 4.2 кодом, подобным этому:
func collectionView(_ collectionView: NSCollectionView, viewForSupplementaryElementOfKind kind: NSCollectionView.SupplementaryElementKind, at indexPath: IndexPath) -> NSView {
let view = collectionView.makeSupplementaryView(ofKind: "?????", withIdentifier: NSUserInterfaceItemIdentifier(rawValue: "Header"), for: indexPath as IndexPath) as! Header
view.sectionTitle.stringValue = collectionSections[indexPath.section]
return view
}
Мне неясно, что я должен включить для параметра ofKind
(String
).Что бы эта строка соответствовала?Я не вижу ничего другого, с чем это можно связать в моем файле xib.