Reputation: 2991
I'm having a strange issue with Firebase. I'm saving data to the server but the completion block is never fired:
//get the current user and update the info
let fbID:String = userData?.objectForKey("facebookID") as! String;
let ref = Firebase(url:self.FIREBASE_URL)
let userRef = ref.childByAppendingPath("user").childByAppendingPath(fbID)
let update = ["work" : work , "school" : school, "description": about]
userRef.updateChildValues(update, withCompletionBlock: { (error:NSError?, ref:Firebase!) in
print("This never prints in the console")
})
The data is saved perfectly on the Firebase server, but the completion block is never fired.
I've tried wrapping the callback on the main thread, and that doesn't make a difference:
userRef.updateChildValues(update, withCompletionBlock: { (error:NSError?, ref:Firebase!) in
dispatch_async(dispatch_get_main_queue()) {
print("This never prints in the console")
}
})
Has anyone else seen this before?
Upvotes: 1
Views: 3217
Reputation: 1586
my implementation about the updateChildValues withCompletionBlock:
db.child(id).updateChildValues(dict, withCompletionBlock: {error, ref in
if error != nil{
print("ERROR")
}
else{
print("ok")
}
})
and its working absolutely fine.
Upvotes: 0
Reputation: 35648
The code works, and the block is called and prints to the console with the following modifications:
//get the current user and update the info
let work:String = "work value"
let school:String = "school value"
let about:String = "about value"
let fbID:String = "key_0"
let userRef = myRootRef.childByAppendingPath("user").childByAppendingPath(fbID)
let update = ["work" : work , "school" : school, "description": about]
userRef.updateChildValues(update, withCompletionBlock: { (error:NSError?, ref:Firebase!) in
print("This never prints in the console")
})
I would investigate the variables; in particular the reference that used to build the userRef.
Upvotes: 1