我正在用Swift语言和一个方法创建一个UITableViewController
override func tableView(tableView: UITableView?, cellForRowAtIndexPath indexPath: NSIndexPath?) -> UITableViewCell?
我得到了这个错误
NSIndexPath?在Swift中没有成员名称'row‘错误
我不明白为什么。
这是我的代码
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呢?
https://stackoverflow.com/questions/24040405
复制相似问题