-1
虽然看了很多帖子,却找不到解决我的情况。如何用Relationship Swift显示UITableView 3
有实体天和有实体任务。每一天可以有0个或多个任务。我需要在UITableView中显示特定日期的任务列表。
如何通过对关系获取行(任务)的数量:
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
}
,然后如何为单元格的格式:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath)-> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TodayCell", for: indexPath as IndexPath) as! TodayTableViewCell
let task = //how to get task?
cell.taskDescription?.text = task.descritpion
return cell
}
你不取的行数,你将需要创建数据源与您的过滤结果并将其计数传递给行数 –
您是如何声明任务和天变量的? –
你应该有包含任务对象的数组,然后你可以这样选择一个任务。让task = tasks [indexPath.row],行数应该返回tasks.count –