0

此代码会根据模拟器的要求保存到 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")
            })
4

1 回答 1

0

通过将 Swift 字符串转换为 NSString 来修复此行为。

如下:

customersRef.child(u.id!).child(("deals" as NSString)).childByAutoId().setValue("true") { error, dbRef in
                print("Is now always called")

        }
于 2017-04-15T16:55:24.540 回答