ios - 错误: Use the unresolved identifier 'indexPath'

标签 ios swift

..请帮忙..谢谢..: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/

相关文章:

ios - 如何以编程方式展开到另一个 Storyboard中的 ViewController?

ios - 撤消重做操作

ios - 无法制作 outlet Swift IOS 开发

iphone - 如何添加此共享按钮? IOS8 与 swift

objective-c - iOS 私有(private)框架

ios - 介绍 MFMessageComposeViewController/理解 DispatchQueue.main.async

ios - 创建 UICollectionViewCell 时 subview 框架不正确

swift - Webkit 与 SFSafariViewController 和核心数据

swift - 快速获取用户所在国家/地区

ios - 稍后在应用程序中使用 prepareForSegue 将数据传递给 ViewController