【发布时间】:2017-06-27 14:21:43
【问题描述】:
嘿,我正在尝试创建一个遍历整个数组的 if 语句,然后询问该索引是否是数组中的最后一个。
这是我目前所拥有的。
代码:
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")
}
}
更新:
其实我认为这可行,但我会接受其他答案
【问题讨论】:
-
if indexPath.row == notificationList.count - 1 { ... }