Firebase setValue() 在模拟器中有效,但在设备上无效,有人知道为什么吗? iOS10,Swift3.1
Firebase setValue() works in simulator but not on device, anyone know why? iOS 10, Swift 3.1
此代码会根据模拟器的要求保存到 Firebase 数据库,但不会在设备上调用完成处理程序。有谁知道为什么或可能的解决方法?
var customersRef : FIRDatabaseReference {
return dbRef.child("customers")
}
func saveDealData(dealBuilder: DealBuilder, errMsgHandler: ErrMsgHandler?) {
print("Shown in log in sim and device")
customersRef.child(u.id!).child("deals").childByAutoId().setValue("true") { error, dbRef in
print("Is called for sim but not device")
}
}
我尝试去掉尾随闭包并将 setValue() 放入内部,如下所示,但同样的事情发生了:
customersRef.child(u.id!).child("deals").childByAutoId().setValue("true", withCompletionBlock: { error, dbRef in
print("Is called in sim but not device")
})
此行为已通过将 Swift 字符串转换为 NSString 得到修复。
如下:
customersRef.child(u.id!).child(("deals" as NSString)).childByAutoId().setValue("true") { error, dbRef in
print("Is now always called")
}
此代码会根据模拟器的要求保存到 Firebase 数据库,但不会在设备上调用完成处理程序。有谁知道为什么或可能的解决方法?
var customersRef : FIRDatabaseReference {
return dbRef.child("customers")
}
func saveDealData(dealBuilder: DealBuilder, errMsgHandler: ErrMsgHandler?) {
print("Shown in log in sim and device")
customersRef.child(u.id!).child("deals").childByAutoId().setValue("true") { error, dbRef in
print("Is called for sim but not device")
}
}
我尝试去掉尾随闭包并将 setValue() 放入内部,如下所示,但同样的事情发生了:
customersRef.child(u.id!).child("deals").childByAutoId().setValue("true", withCompletionBlock: { error, dbRef in
print("Is called in sim but not device")
})
此行为已通过将 Swift 字符串转换为 NSString 得到修复。
如下:
customersRef.child(u.id!).child(("deals" as NSString)).childByAutoId().setValue("true") { error, dbRef in
print("Is now always called")
}