iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on September 12, 2015, 04:00:23 AM

Title: How to fix problems with the table view indexPathForSelectedRow in Swift 2.0
Post by: kjmcneish on September 12, 2015, 04:00:23 AM
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 (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 (https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8)