func
でfunc
で私のコードをSwift 3に変換しようとしました。今私はエラーがなく、いくつかの警告がありますが、いくつかの関数は実行されていないという問題があります。この原因は何ですか?FirebaseとSwift 3コードがもう実行されていません
私はこれらの機能が故障していると仮定しています。これは、私が何も得られていない部分だからです。print
。私に教えてください
//With this I get selected brand products values like product name, nicotine, flavor etc..
let ref = FIRDatabase.database().reference().child("Snuses").queryOrdered(byChild: "Brand").queryEqual(toValue: brandName)
ref.observeSingleEvent(of: .value, with: { (snapshot) in
if snapshot.exists(){
if let products = (snapshot.value as AnyObject).allValues as? [[String:AnyObject]]{
self.productsValue = products
self.productsTable.reloadData()
}
}
})
//With this fucntion I get the products count.
let ref = FIRDatabase.database().reference().child("Snuses").queryOrdered(byChild: "Brand").queryEqual(toValue: filteredBrands[indexPath.row])
ref.observeSingleEvent(of: .value, with: { (snapshot) in
if snapshot.exists(){
if let products = (snapshot.value as AnyObject).allValues as? [[String:AnyObject]]{
var count = (snapshot.childrenCount)
snusProductCountLabel.text = "\(count) products"
}
}
})
//Parse snus brands
func parseSnuses(){
let ref = FIRDatabase.database().reference().child("Brands").queryOrderedByKey()
ref.observe(.childAdded, with: { (snapshot) in
self.brands.append(snapshot.key)
print(snapshot.key)
self.snusBrandsTableView.reloadData()
}){ (error) in
}
私は違う何かできること:
これらは、スウィフト3で前に働いていたではなく、私の機能の一部です!それらの機能は異なるViewControllers
にあります。
編集:これは私のJSONツリーです
{
"Snuses" : {
"Catch Eucalyptus White Large" : {
"Brand" : "Catch",
"Products" : "Catch Eucalyptus White Large",
"PorionWeight" : 21.6,
"flavor" : "Tobacco, Eucalyptus",
"nicotine" : 8.0,
"PortionsCan" : 24,
"shipping weight" : 39
},
そして、これらのセキュリティルールです:
{
"rules": {
".read": "true",
".write": "true",
"Snuses": {
".indexOn": "Brand"
}
}
}
エラーの点では、正確には何を見ていますか?何が問題なのか明確ではありません... – BHendricks
何も与えていないコードだけのエラーはありません。 –
"何も与えていない"という意味は?コードは何を "あなたに"与えるべきですか? – BHendricks