gpt4 book ai didi

ios - Firebase 完成 block

转载 作者:行者123 更新时间:2023-11-28 06:47:19 25 4
gpt4 key购买 nike

我在使用 Firebase 时遇到了一个奇怪的问题。我正在将数据保存到服务器,但从未触发完成 block :

        //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")

})

数据完美保存在 Firebase 服务器上,但从未触发完成 block 。

我试过在主线程上包装回调,这没有什么区别:

        userRef.updateChildValues(update, withCompletionBlock: { (error:NSError?, ref:Firebase!) in
dispatch_async(dispatch_get_main_queue()) {
print("This never prints in the console")
}
})

有没有人见过这个?

最佳答案

代码有效, block 被调用并通过以下修改打印到控制台:

//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")

})

我会调查变量;特别是用于构建 userRef 的引用。

关于ios - Firebase 完成 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35946565/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com