【发布时间】:2019-03-10 20:08:04
【问题描述】:
我在 UITableView 中使用 2 个 Realm 对象作为数据源:
class SectionDate: Object {
@objc dynamic var date = Date()
let rowDates = List<RowDate>()
}
class RowDate: Object {
@objc dynamic var dateAndTime = Date()
}
tableViewData = realm.objects(SectionDate.self).sorted(byKeyPath: "date", ascending: isAscending)
func numberOfSections(in tableView: UITableView) -> Int {
return tableViewData.count
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return tableViewData[section].rowDates.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
...
cell.rowDate = tableViewData[indexPath.section].rowDates[indexPath.row]
...
}
我将如何订购 section.rowDate ,何时订购?
看起来我不能将其作为 section.sorted(byKeyPath) 查询的一部分来执行...我会在 SectionDate 对象的初始化时执行此操作吗?
【问题讨论】:
标签: swift uitableview realm