【发布时间】:2015-07-20 19:32:54
【问题描述】:
我有一个表格视图,单击单元格,它会进入另一个表格视图。第一个 tableview 工作并加载适当的数据。第二个不显示数据。这是我的代码:
let query = PFQuery(className: "_User")
query.whereKey("Chemistry", equalTo: true)
query.findObjectsInBackgroundWithBlock { (caption: [AnyObject]?, erreur: NSError?) -> Void in
if erreur == nil {
// on a réussi
for caption in caption! {
self.chemistryListe.append(caption["username"] as! String)
}
println("we are here")
println(self.chemistryListe)
}
else {
// quelque chose s'est passé
}
}
这是我的 cellforRowatIndexPath 和 numberOfRowsinSection 方法:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.chemistryListe.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("SearchResult") as! CompanyTableViewCell
println(self.chemistryListe)
cell.nameLabel.text = chemistryListe[indexPath.row]
return cell
}
如果我改变这一行:
cell.nameLabel.text = chemistryListe[indexPath.row]
到这里:
cell.nameLabel.text = "testcell"
然后一切正常,并正确显示文本“testcell”。所以很明显,没有读到 chemistryListe 数组中有任何内容。但是我在查询中间设置了一个断点,并看到查询正确地获取了应该在数组中的数据,并将其放入数组中。但只是 tableview 单元格没有读取它。知道有什么问题吗?谢谢
【问题讨论】:
标签: ios swift uitableview parse-platform