kylar13 kylar13 - 1 year ago 140
iOS Question

cellForRow(at: IndexPath) in swift 3 is acting funny in XCode 8

I'm trying to recover a cell from a TableView using the method cellForRow(at: IndexPath) but the compiler doesn't seem to like this method because it won't let me call it :S (Can't post images yet)

Here's the snippet of the code in question:

if let i = snapshot.value as! String) {[i] = snapshot.value as! String

self.tableView.cellForRow(at: i).textLabel!.text = "Modd"

self.tableView.cellForRow(at: [IndexPath(row: i, section: 0)])!.textLabel!.text = "mod"
else {

print("Modified an item that wasn't in the data list")

How should I be calling the method if the compiler accepts neither of the two?

Answer Source

Your problem with your second statement is that you add the indexPath that you create to an array.

Use the following code:

self.tableView.cellForRow(at: IndexPath(row: i, section: 0))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download