【问题标题】:UILocalizedIndexedCollation with array of strings带有字符串数组的 UILocalizedIndexedCollat​​ion
【发布时间】:2015-03-09 18:59:46
【问题描述】:

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

【问题讨论】:

    标签: ios swift uilocalizedcollation


    【解决方案1】:

    字符串类型可以使用selfdescription。我更喜欢self,因为它可以用于任何类型。使用 self 时,你会比较对象本身

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-11
      • 2020-03-30
      • 2015-09-19
      相关资源
      最近更新 更多