简体   繁体   English

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

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

I'm trying to retrieve the FirebaseUser provider's data, but Swift debugger is returning the error 我正在尝试检索FirebaseUser提供程序的数据,但是Swift调试器返回了错误

Cannot call value of non-function type '[UserInfo]' 无法调用非功能类型“ [UserInfo]”的值

as can be seen in my code in the picture below: 从下面的图片中我的代码可以看出:

码

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

Can someone tell me what's wrong? 有人可以告诉我怎么了吗?

providerData is an array property of FIRUser check Here , that you can't use { after it , so you need 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