Author Topic: How to fix problems with the table view indexPathForSelectedRow in Swift 2.0  (Read 3619 times)

kjmcneish

  • Administrator
  • *****
  • Posts: 719
    • View Profile
In Swift 2.0, the indexPathForSelectedRow() method has been changed to a property, so you need to remove the parentheses when referencing it.

For example, the following code references the method:

Code: [Select]
let indexPath = self.tableView.indexPathForSelectedRow()!
And should be changed to:

Code: [Select]
let indexPath = self.tableView.indexPathForSelectedRow!
All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8
« Last Edit: November 15, 2015, 10:12:01 AM by kjmcneish »