UILocalizedIndexedCollat​​ion包含字符串数组

时间:2015-03-09 18:59:47

标签: ios swift uilocalizedcollation

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对象上使用哪个选择器?

1 个答案:

答案 0 :(得分:2)

您可以将selfdescription用于字符串类型。我更喜欢self因为它可以用于任何类型。使用self时,您可以自己比较对象

let selector: Selector = "self"
let selector: Selector = "description"