..请帮忙..谢谢..: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
}
}
最佳答案
试试这个:
// 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
}
关于ios - 错误: Use the unresolved identifier 'indexPath' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31650411/