【发布时间】:2015-07-21 02:52:49
【问题描述】:
我一直在尝试在单元格中打印我的viewWillAppear 中调用的PFQuery,但我从这一行得到了错误:
cell?.textLabel?.text = message as NSString as String
这是tableView的代码cellForRowAtIndexPath:
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellId: NSString = "cell"
var cell: UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(cellId as String) as? UITableViewCell
if (cell == nil) {
cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: cellId as String)
}
let message = myMessagesArray![indexPath.row] as! PFObject
cell?.textLabel?.text = message as NSString as String
return cell!
}
这是PFQuery:
var query = PFUser.query()
query!.orderByAscending("Messages")
query!.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
println("Successfully retrieved \(objects!.count) messages.")
self.myMessagesArray = objects
self.tableView?.reloadData()
} else {
println(error!.localizedDescription)
}
}
【问题讨论】:
-
好的,所以“消息”是一个 PFObject。您不想分配该对象,而是分配它的一个字段,不是吗?
-
如果您想在控制台中查看消息的内容,您可以使用
println(message)进行调试。 @freytag 可能为您指明了正确的方向。
标签: ios swift uitableview parse-platform