gpt4 book ai didi

swift - 显示 Parse 数据库 Swift 中单元格的两个键

转载 作者:行者123 更新时间:2023-11-30 14:08:38 25 4
gpt4 key购买 nike

我想获取“firstName”和“lastName”关键属性并将其显示在单元格中。这是我所拥有的:

required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

self.parseClassName = "User"
//Right now, it'll only display the first name
self.textKey = "firstName"
}

override func queryForTable() -> PFQuery {
let query = PFUser.query()

query?.whereKey("firstName", containsString: searchString)
return query
}

如何存储同时具有“firstName”和“lastName”属性的变量?

最佳答案

您可以在 tableview 委托(delegate)方法中执行此操作。

 override func tableView(tableView:UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {

var cell = tableView.dequeueReusableCellWithIdentifier("cell") as! PFTableViewCell!


if cell == nil {


cell = PFTableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "cell")
}
// Extract values from the PFObject to display in the table cell

if let customerFirstName = object?["FirstName"] as? String {
cell?.textLabel?.text = customerFirstName
}

if let customerLastName = object?["customerLastName"] as? String {
cell?.detailTextLabel?.text = customerStreetAddress
}

return cell

}单击表格 View 的单元格,然后转到检查器疼痛并将样式更改为“字幕”

enter image description here

关于swift - 显示 Parse 数据库 Swift 中单元格的两个键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32028502/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com