I am trying to get some users' profile pictures. Here is the code I am starting with:
databaseRef.child("Users").queryOrderedByKey().observeSingleEvent(of: .childAdded) { (snapshot) in
}
I am trying to follow a Swift 2 tutorial; however, I am using Swift 3. I have tried to adjust the code already, but I have not been successful as I get the following error
Ambiguous use of 'observeSingleEvent(of:with:)'
This error is on the first line. How can I resolve this? Thanks!
Working solution for Swift 3:
databaseRef.child("Users").queryOrderedByKey().observe(.childAdded, with: { snapshot in
})
The problem here with the block in the end of this line :
databaseRef.child("Users").queryOrderedByKey().observeSingleEvent(of: .childAdded) { (snapshot) in
}
since there is many implementation to the function observeSingleEvent
the compiler is getting confused which to choose.
databaseRef.child("Users").queryOrderedByKey().observeSingleEvent(of: .childAdded,
with: { snapshot in
// Do whatever you want with the snapshot
})
Hope this helps someone
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With