尝试检索提供程序的数据时,如何解决“无法调用非功能类型[UserInfo]的值”的问题?

时间:2019-02-07 23:07:50

标签: ios swift firebase firebase-authentication

我正在尝试检索FirebaseUser提供程序的数据,但是Swift调试器返回错误

  

无法调用非功能类型'[UserInfo]'的值

在下面的图片中可以从我的代码中看到:

code

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 = .....
        }
    }
}

有人可以告诉我怎么了吗?

1 个答案:

答案 0 :(得分:2)

providerDataFIRUser检查Here的数组属性,您不能在其后使用 {,因此您需要

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 = .....
    }
}