Swift - How to check if TableView is empty
In Swift 3:
if tableView.visibleCells.isEmpty {
//tableView is empty. You can set a backgroundView for it.
} else {
//do something
}
You should check taskMgr.tasks.count
value.
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
if taskMgr.tasks.count == 0 {
//table view is empty here
}
return taskMgr.tasks.count
}