I'm trying to sort in different labels every items of a dictionary (in my exemple:vote in firebase go in the specify "votelabel", text in "textlabel" ... ), I tried to do it this way but I realy get stock. I think my problem is because every post have a new key and I don't Know How to go directly to the children
var posts: [String: AnyObject] = [String: AnyObject]()
@IBAction func save(sender: AnyObject) {
let titre = Titre.text
let soustitre = SousTitre.text
let text = Text.text
let newPosts: Dictionary<String, AnyObject> = [
"titre": titre!,
"soustitre": soustitre!,
"text": text!,
"votes": votes
]
ref.childByAppendingPath(current).childByAppendingPath("Posts").childByAutoId().setValue(newPosts)
ref.childByAppendingPath(current).observeEventType(.ChildAdded, withBlock: { snapshot in
print(snapshot.value)
from here I realy get lost, I find this part on a tutorial, but to be honnest I didn't get it.
var posts = [NSDictionary]()
for item in snapshot.children{
let child = item as! FDataSnapshot
let dict = child.value as! NSDictionary
posts.append(dict)
}
self.TextLabel.text = snapshot
})
}
any clue will be very usefull !
thank you for your time !