Reputation: 1391
Hey I'm trying to create a if statement that goes through the entire array and then asks if that index is the last one in the array.
This is what I have so far.
Code:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { // Called for each cell made
if notificationList[indexPath.row] == notificationList.last! {
print("At last index")
}
}
UPDATE:
Actually I think this works but I will take other answers
Upvotes: 1
Views: 2892
Reputation: 651
Check like below
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.row == notificationList.count - 1 {
print("At last index")
}
}
Upvotes: 5