簡體   English   中英

Firebase setValue()可在模擬器中使用,但不能在設備上使用,有人知道為什么嗎? iOS 10,Swift 3.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")

        }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM