我正在尝试从另一个屏幕呈现表格视图信息,我收到此错误消息:
输入'[[string:string]]'?没有下标成员
class TestListViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
let userTest = DataManager.getInstance().getRecord()
let arrayOfDateString = DataManager.getInstance().getArrayOfKeys()
override func viewDidLoad() {
super.viewDidLoad()
}
@IBOutlet weak var tableView: UITableView!
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return userTest!.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as UITableViewCell
// cell.textLabel?.text = userTest[indexPath.row] - **here is the problem
cell.detailTextLabel?.text = "Your record"
return cell
}
}
答案 0 :(得分:1)
更改此代码 -
cell.textLabel?.text = userTest[indexPath.row]
到此代码 -
cell.textLabel?.text = userTest![indexPath.row]