In Firebase 3.0+ the method to get the database reference was as such:
var ref: FIRDatabaseReference!
ref = FIRDatabase.database().reference()
ref.child("rooms").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
if snapshot.hasChild("room1"){
print("true rooms exist")
}else{
print("false room doesn't exist")
}
})
In Firebase 4.0 the naming convention changed but I can't get it to work!?
var ref: DatabaseReference!
ref = Database.database().reference()
Has anyone else encountered this?
The swift compiler is suggesting removing the () from the lowercase database function call
if you remove it, it then throws the error message:
- Database has no member reference
So how do you get the reference then!?
Pod file:
pod 'Firebase/Core'
pod 'Firebase/Database'