【发布时间】:2018-12-14 01:03:27
【问题描述】:
下面的代码在单个表格视图单元格中打印 2 个核心数据属性。我希望每个单元格都以这种方式排序。属性 1 a - z 属性 2 z -a。这意味着如果集合是(b,b),(b,a),(a,a)。它将打印 (a,a),(b,a),(bb)。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let title = itemsName[indexPath.row]
let cell = tazbleView.dequeueReusableCell(withIdentifier: "cell", for : indexPath)
let attr1 = title.value(forKey: "lorde") as? String
let attr2 = title.value(forKey: "num") as? String
cell.textLabel?.text = [attr1, attr2].flatMap { $0 }.reduce("", +)
return cell
}
【问题讨论】:
标签: uitableview sorting core-data tableview swift4