0
这里的仪表盘为iOS应用程序:检索名称从火力地堡,以表视图
{
"users" : {
"0b71693a-4f16-4759-acd6-706da1a466a0" : {
"Picker" : "Jubail",
"details" : "iOS second",
"name" : "Huda"
},
"16b13b1e-0025-4eee-a590-5bbacc52071c" : {
"Picker" : "Jeddah",
"details" : "Hellom from the Internet",
"name" : "Rania"
},
"394b6555-1838-4565-87ac-e423c3b89cf1" : {
"Picker" : "Jubail",
"details" : "",
"name" : "Marwa"
},
}
}
我想检索其选择器是朱拜勒到表格视图单元所有用户的名字!
我是如此初学者,我不知道该怎么做! 我想,这是我做的代码:
import UIKit
class CookingViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var BusinessName:[String: String] = [String:String]()
let ref = Firebase (url: "https://mariahfinaltest.firebaseio.com")
@IBOutlet weak var CookingTableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
ref.queryOrderedByChild("Picker").queryEqualToValue("Riyadh")
.observeEventType(.Value, withBlock: { snapshot in
for child in snapshot.children {
self.BusinessName = child.value["name"] as! [String: String]
}
self.CookingTableView.reloadData()
})
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5 //It should not be 5 here! How Can I make it as long as cells?
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.CookingTableView.dequeueReusableCellWithIdentifier("CookingCell", forIndexPath: indexPath) as! CookingTableViewCell
var keys: Array = Array(self.BusinessName.keys)
cell.BusinessNameLabel.text = BusinessName[keys[indexPath.row]] as String!
return cell
}
}
我不断收到错误! 我不知道什么是错的!
我明白我最后的错误,它的工作,也有一个与火力URL的一个问题!我没有在网址中添加“/ users”。 – Mariah
@Jay请回答这个问题http://stackoverflow.com/questions/42646255/retrieve-all-child-value-to-a-label-in-table-view-cell –
@Xcodian你有问题吗?如果是这样,请发布它,以便我们可以看看您的使用案例! – Jay