uniqueOrganizationsArray
属于[String]
类型。
private let collation = UILocalizedIndexedCollation.currentCollation() as UILocalizedIndexedCollation
private var sections: [[String]] = []
let selector: Selector = ""
sections = [[String]](count: collation.sectionTitles.count, repeatedValue: [])
for object in uniqueOrganizationsArray {
let sectionNumber = collation.sectionForObject(object, collationStringSelector: selector)
sections[sectionNumber].append(object as String)
}
我应该在String
对象上使用哪个选择器?
答案 0 :(得分:2)
您可以将self
或description
用于字符串类型。我更喜欢self
因为它可以用于任何类型。使用self时,您可以自己比较对象
let selector: Selector = "self"
let selector: Selector = "description"