// Das Beispiel unten arbeitet groß Ich bekomme das Layout, wie es aussehen sollte, aber ich möchte das Wörterbuch aus der Firebase-Funktion unten generieren.wie man Wörterbuch mit Schlüssel zur Tabellenansicht
Es sollte so etwas aussehen und ich möchte die Daten in die Tabelle. Ich bin nicht sicher, ob ich Schleife sein sollte. die Art, wie es unten ist, bringt den folgenden Fehler "fataler Fehler: unerwartet gefunden Null beim Entpacken eines optionalen Wertes" die Variablen sind nicht Null, wenn ich sie drucke, bekomme ich Daten zurück.
ref.childByAppendingPath("backend/posts").queryOrderedByChild("requestFrom").queryEqualToValue(ref.authData.uid).observeEventType(.ChildAdded, withBlock: {snapshot in
var firstname = snapshot.value["firstname"] as! String
var lastname = snapshot.value["lastname"] as! String
self.data = [
[
"firstname": firstname,
"lastname": lastname
]
]
print(self.data)
})
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! statusPrototypeCell
let object = data[indexPath.row]
cell.firstname.text = object["firstname"] as! String
cell.lastname.text = object["lastname"] as! String
return cell
}
override func viewWillAppear(animated: Bool) {
navigationController?.navigationBarHidden = false
navigationController?.navigationBar.barTintColor = UIColor(red:0.4, green:0.76, blue:0.93, alpha:1.0)
navigationController?.navigationBar.translucent = false
self.title = "Signup"
self.navigationController?.navigationBar.tintColor = UIColor.whiteColor()
navigationController?.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor()]
}
}
'[:]' ist ein Wörterbuch kein Array –
Sie sind richtig. – pprevalon