簡體   English   中英

嘗試檢索提供程序的數據時,如何解決“無法調用非函數類型[UserInfo]的值”的問題?

[英]How to fix “Cannot call value of non-function type [UserInfo]” while trying to retrieve provider's data?

我正在嘗試檢索FirebaseUser提供程序的數據,但是Swift調試器返回了錯誤

無法調用非功能類型“ [UserInfo]”的值

從下面的圖片中我的代碼可以看出:

碼

let providData = userInstance.providerData {
    for profile in providerData {
        if profile.providerID == "facebook.com" {
            let fbUserId = profile.uid
            fbProfilePicUrl = "https://graph.facebook.com/\(fbUserId)/picture?height=300"
            self.profilePicUrl = fbProfilePicUrl
        }else if profile.providerID == "google.com" {
            let googleUserId = profile.uid
            //self.profilePicUrl = .....
        }
    }
}

有人可以告訴我怎么了嗎?

providerDataFIRUser check 在此處的數組屬性,您不能在其后使用{ ,因此您需要

for profile in user.providerData {
    if profile.providerID == "facebook.com" {
        let fbUserId = profile.uid
        fbProfilePicUrl = "https://graph.facebook.com/\(fbUserId)/picture?height=300"
        self.profilePicUrl = fbProfilePicUrl
    }else if profile.providerID == "google.com" {
        let googleUserId = profile.uid
        //self.profilePicUrl = .....
    }
}

暫無
暫無

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

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