首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >NSIndexPath?在Swift中没有成员名称'row‘错误

NSIndexPath?在Swift中没有成员名称'row‘错误
EN

Stack Overflow用户
提问于 2014-06-04 22:36:23
回答 4查看 16.1K关注 0票数 20

我正在用Swift语言和一个方法创建一个UITableViewController

代码语言:javascript
复制
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?

我得到了这个错误

NSIndexPath?在Swift中没有成员名称'row‘错误

我不明白为什么。

这是我的代码

代码语言:javascript
复制
import UIKit

class DPBPlainTableViewController: UITableViewController {

    var dataStore: NSArray = NSArray()

    override func viewDidLoad() {
        super.viewDidLoad()
        self.dataStore = ["one","two","three"]

        println(self.dataStore)
    }


    // #pragma mark - Table view data source

    override func numberOfSectionsInTableView(tableView: UITableView?) -> Int {

        // Return the number of sections.
        return 1
    }

    override func tableView(tableView: UITableView?, numberOfRowsInSection section: Int) -> Int {

        // Return the number of rows in the section.
        return self.dataStore.count
    }


    override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell? {
        let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "Cell")

        cell.textLabel.text = self.dataStore[indexPath.row]

        return cell
    }

}

那么,如何使用数组dataStore元素设置cell.text呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24040405

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档