Tenho uma Tableview de mensagens, gostaria de saber como faço para adicionar sections usando o campo date do objeto NotificationItem.
struct NotificationItem: Codable {
let title: String
let body: String
let date: Date
let link: String
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if notificationStore.items.count == 0 {
self.viewSemNotificacoes.isHidden = false
} else {
self.viewSemNotificacoes.isHidden = true
}
return notificationStore.items.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if let newsCell = cell as? NotificationItemTableViewCell {
newsCell.updateWithNewsItem(notificationStore.items[indexPath.row])
}
return cell
}