【发布时间】:2018-01-15 00:22:27
【问题描述】:
在我的带有 tableView 的 viewController 中,我有使用 fetchedResultsController 从核心数据数据库中获取的对象列表。我按部分对所有获取的结果进行了分组。它工作正常,我已经实现了以下方法来启用出现在 TableView 右侧的 A-Z sectionIndexes:
func sectionIndexTitles(for tableView: UITableView) -> [String]? {
let indexTitles = self.fetchedResultsController.sectionIndexTitles
return indexTitles
}
func tableView(_ tableView: UITableView, sectionForSectionIndexTitle title: String, at index: Int) -> Int {
return self.fetchedResultsController.section(forSectionIndexTitle: title, at: index)
}
我也有这个fetchedResultsController的声明
var fetchedResultsController: NSFetchedResultsController<Object>!
self.fetchedResultsController = NSFetchedResultsController(fetchRequest: fetchRequest, managedObjectContext: context!, sectionNameKeyPath: "project.group.name", cacheName: nil)
sectionIndexTitles 工作正常,而我的核心数据数据库中有 group.name 的英文值,但是当我有另一种语言(或英语与非英语混合)的 group.name 值时,sectionIndexTitles 正在显示(返回)我英文字母,但对于非英文字母,它返回我问号或英文字母。
例如,它返回这样的数组["A", "B", "F", "G", "R", "S", "A", "E"],而不是返回这样的数组["A", "B", "F", "G", "R", "S", "Letter in another language", "Letter in another language"]。
我更改了语言方案,它返回["A", "B", "F", "G", "R", "S", "?", "?"]。
它用英文字母或显示“?”代替非英文字母,而不是用另一种语言显示值。
不确定这是否是错误?或者它可能无法显示不同语言的字母。问题可能出在哪里以及如何解决?
我使用的是 Swift 3,Xcode 8.3.3。
【问题讨论】:
标签: swift uitableview core-data swift3 tableview