0

..Please Help..thank you.. :D

Error: Use the unresolved identifier 'indexPath'

import Foundation

class BackTableVC: UITableViewController{

var TableArray  = [String]()

override func viewDidLoad() {

    TableArray = ["HOME","MEN","WOMEN"]

}

func tableView(tableView: UITableView, numberofROwsInSection section: Int) -> Int {
     return TableArray.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath: NSIndexPath) -> UITableViewCell {
    var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell

    cell.textLabel?.text = TableArray[NSIndexPath.row]

    return cell

}
}
Bhavin Bhadani
  • 22,224
  • 10
  • 78
  • 108
RH34Serenity
  • 23
  • 1
  • 8
  • 1
    your `tableView` delegate method is incorrect, it should have an `indexPath` variable, and you should use that instead of `NSIndexPath.row`, the correct one is `indexPath.row` – Dániel Nagy Jul 27 '15 at 10:14

2 Answers2

0

Try this:

   // add indexPath
   func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as UITableViewCell

    // use indexPath not NSIndexPath
    cell.textLabel?.text = TableArray[indexPath.row]

    return cell
    }
Greg
  • 25,317
  • 6
  • 53
  • 62
0

Replace your override cellForRowAtIndexPath method with below:

    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
        //Your Logic
        let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! UITableViewCell
        cell.textLabel?.text = TableArray[indexPath.row]
        return cell
    }
Sohil R. Memon
  • 9,404
  • 1
  • 31
  • 57