I'm still trying to access all the nodes but when I'm writing this code I'm getting the error written below. I would like to print "yes" for golf if this sport is in my database.
Everything works before the line let dict = snap.value as! [String: any]. ie I can write the different snaps, but then it crashes.
All the elements in my database are strings, even the coordinates. You can find a picture of my database with the link below.
@IBAction func testbutton(_ sender: UIButton) {
Database.database().reference().child("users").observe(.childAdded) { (snapshot) in
for child in snapshot.children {
print(child)
let snap = child as! DataSnapshot
print(snap)
let dict = snap.value as! [String: Any]
let msg = dict["golf"] as! String
print(msg)
Error:
___________________________________________________
Could not cast value of type 'NSTaggedPointerString'
(0x7fff87a91958) to 'NSDictionary' (0x7fff87a91c78).
2020-07-21 13:18:24.131870+0200 Joiny[43447:2152693]
Could not cast value of type 'NSTaggedPointerString'
(0x7fff87a91958) to 'NSDictionary' (0x7fff87a91c78).
_______________________________________________________
Picture of my database ->
