Ich habe versucht, meinen Code func
von func
zu Swift 3 zu konvertieren. Ich muss sagen, dass ich zuvor voll funktionsfähiges Projekt hatte. Jetzt habe ich ein Problem, wo ich keine Fehler und nur einige Warnungen habe, aber einige der Funktionen werden nicht ausgeführt. Was sollte das verursachen?Firebase und Swift 3 Code nicht mehr ausgeführt
Ich gehe nur davon aus, dass diese angegebenen Funktionen fehlerhaft sind, weil dies die Teile sind, wo ich nichts bekomme, sogar print
.
Dies sind einige meiner Funktionen, die vorher gearbeitet, aber nicht mit Swift 3:
//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
}
Alles, was ich kann mir nicht anders bitte sagen! Diese Funktionen sind in verschiedenen ViewControllers
.
Edit: das ist mein JSON Baum
{
"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
},
Und das sind Sicherheitsregeln:
{
"rules": {
".read": "true",
".write": "true",
"Snuses": {
".indexOn": "Brand"
}
}
}
Was genau sehen Sie in Bezug auf Fehler? Nicht klar, was das Problem ist ... – BHendricks
Keine Fehler nur der Code nichts zu geben. –
Was bedeutet dann "Code nicht geben"? Was soll der Code "dir geben"? – BHendricks