I\'ve been pulling my hair out because of this. Going to all the pages with related incidents and multiple tutorials I find nothing wrong with my code here, but somehow it o
Just some coding errors
Remove: (snapshot)-> Void
Change: child in snapshot as snapshot is not a sequence, whereas snapshot.children is
I assume you want to store the friends name as a string and name is a key in your structure. So change self.friendsList.append(child.value) to
let name = child.value["name"] as? String
friendsList.append(name!)
Here's the corrected code:
var friendsList = [String]()
ref.observeSingleEventOfType(.Value, withBlock: { snapshot in
if snapshot.value is NSNull {
} else {
for child in snapshot.children {
let name = child.value["name"] as? String
friendsList.append(name!)
}
print("\(friendsList)")
}
})
ref.observeSingleEvent(of: .value, with: { (snapshot) -> Void in
})
Work for me, Xcode 8.3.2