正在使用 Xcode 7 和 swift 2。应用程序运行良好。更新到 Xcode 8。它自动从 swift 2 转换代码 --> swift 3。现在我的表格视图的代码有问题。
错误在于这行代码:
if (indexPath as NSIndexPath).row == 0 || indexPath == 1 {
counter = 0
self.performSegue(withIdentifier: "Day1", sender: self)
}
正如它所说,二元运算符'=='不能应用于操作数类型'索引路径'和'int'
这是什么意思,我该如何解决?
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath as NSIndexPath).row == 0 || indexPath == 1 {
counter = 0
self.performSegue(withIdentifier: "Day1", sender: self)
}
if (indexPath as NSIndexPath).row == 1 {
counter = 1
self.performSegue(withIdentifier: "Day2", sender: self)
}
}