【发布时间】:2015-03-29 11:01:23
【问题描述】:
我正在尝试使用 PFQueryTableViewController 填充表。
我想使用来自两个类的数据,即Places 和Details。
在Places 中,我有两列,placeText 作为string,pointerToDetails 作为指针。
在Details 中,我有一列,即detailText。
我想在同一个CustomCell 中显示placeText 和detailText,我已经定义为PFTableViewCell。
不幸的是,在我运行代码之后,我只得到了CustomCell 中的placeText。
import UIKit
class TableViewController: PFQueryTableViewController {
// Initialise the PFQueryTable tableview
override init!(style: UITableViewStyle, className: String!) {
super.init(style: style, className: className)
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
// Configure the PFQueryTableView
self.pullToRefreshEnabled = true
self.paginationEnabled = false
}
// Define the query that will provide the data for the table view
override func queryForTable() -> PFQuery! {
var query = PFQuery(className: "Places")
query.includeKey("pointerToDetails")
return query
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject) -> PFTableViewCell {
var cell = tableView.dequeueReusableCellWithIdentifier("CustomCell") as CustomTableViewCell!
if cell == nil {
cell = CustomTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CustomCell")
}
// Extract values from the PFObject to display in the table cell
cell.name.text = object["placeText"] as String!
cell.detail.text = object["detailText"] as String!
return cell
}
}
【问题讨论】:
标签: ios swift parse-platform pfquery