Updating an old app from swift 2.2 to swift 4. I have to use swift 3 as a stepping stone. I converted to 3 but come across the following error:
Binary operator '==' cannot be applied to operands of type 'IndexPath' and 'Int`
The code is:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath as NSIndexPath).row == 0 || indexPath == 1 {
self.performSegue(withIdentifier: "NFL", sender: self)
}
if (indexPath as NSIndexPath).row == 1 {
self.performSegue(withIdentifier: "AFL", sender: self)
}
if (indexPath as NSIndexPath).row == 2 {
self.performSegue(withIdentifier: "FAI", sender: self)
}
if (indexPath as NSIndexPath).row == 3 {
self.performSegue(withIdentifier: "IPA", sender: self)
}
}
Why do I get this error in Swift 3 and not 2.2? I tried to force it into an "Int" but don't think I was going about it the right way.
indexPath == 1
wouldn't have compiled in Swift 2.2 either, so you are not really telling us the truth here.