在Swift 4中对此表进行排序的最佳实践是什么?
A-Z
override func viewDidLoad() {
super.viewDidLoad()
list = [ ghost(name:"alphabet".localized, id:"1"),
ghost(name:"élephant".localized, id:"2"),
ghost(name:"delegate".localized, id:"3")]
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if filtering() {
return filter.count
}
return list.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "library", for: indexPath)
var data: ghost
if filtering() {
data = filter[indexPath.row]
}
else {
data = list[indexPath.row]
}
cell.textLabel!.text = data.name
return cell
}
我经常使用翻译后的字符串。所以,如果这个表可以用不同的语言按字母顺序加载,那就太好了。有人能帮我一下吗?我找遍了整个互联网,太累了.非常感谢!
https://stackoverflow.com/questions/51635105
复制相似问题