swift3 - Fetching images from Firebase child -
everyone. have troubles fetching chunk of images child in firebase database. doing ios project , using swift 3 , xcode. basically, after all, "image" variable returns "nil" please, me if can. here code using:
let ref = firdatabase.database().reference().child("menu") ref.observesingleevent(of: .value, with: { (snapshot) in if let dictionary = snapshot.value as? [string: anyobject] { let image = dictionary["foodimageurl"] as? string print(image any) // returns nil and example of database structure
i need fetch "foodimageurl" children menu node
your snapshot.value list of sub items menu, not details info of each node, have use foreach, , inside each node, use dictionary["foodimageurl"] as? string image
try this
let ref = firdatabase.database().reference().child("menu") ref.observesingleevent(of: .value, with: { (snapshot) in rest in snapshot.children.allobjects as! [firdatasnapshot] { if let dictionary = rest.value as? [string: anyobject]{ let image = dictionary["foodimageurl"] as? string print(image any) } } 
Comments
Post a Comment