In Firebase 2.5.1, this was working:
let post1Ref = sendRequestRef.childByAutoId()
post1Ref.setValue(request, withCompletionBlock: {( error:NSError?, ref:Firebase!) in
})
However, I couldn't figure out how to achieve it in 3.x (as the docs for completion doesn't really tell it)
let post1Ref = sendRequestRef.childByAutoId()
post1Ref.setValue(request, withCompletionBlock: {( error:NSError?, ref:Firebase!) in
if (error != nil) {
print("ERROR")
} else {
print("Success")
}
})
This throws an error:
Use of unresolved Firebase
What is the proper way of handling completion block with Firebase 3.x?
Use
ref.setValue(object) { (error, ref) -> Void in
}
Here ref is FIRDatabaseReference
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