目前我有 Parse 数据,其中包含图像、标题和价格。
我想获取数据并将其传递给 UITableView,我该怎么做?
我是否查询所有数据并将其设置到每个 UILabel?
目前我有 4 个标签,1 个 ImageView 和 3 个 TextLabel
这是我的 UITableViewController 的代码
class MyTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
queryProducts()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
func queryProducts() {
var query = PFQuery(className:"product")
query.whereKey("playerName", equalTo:"Sean Plott")
query.findObjectsInBackgroundWithBlock {
(objects: [AnyObject]?, error: NSError?) -> Void in
if error == nil {
// The find succeeded.
println("Successfully retrieved \(objects!.count) scores.")
// Do something with the found objects
if let objects = objects as? [PFObject] {
for object in objects {
// What should i put here?
}
}
} else {
// Log details of the failure
println("Error: \(error!) \(error!.userInfo!)")
}
}
}
}
这是tableView Storyboard的截图
再次说明如何将所有 Parse 数据传递给 tableView?
最佳答案
我猜您正在使用 Parse.com 作为后端数据服务。 那么在这种情况下很容易处理数据, 只需从 PFQueryTableViewController 扩展您的 TableViewController 类
class TableViewController: PFQueryTableViewController {
////
}
然后按照下面链接中的说明操作
SWIFT+PARSE 数据管理: LINK
关于ios - 如何将数据从 Parse 传递到 UITableView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30301207/