简体   繁体   中英

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

Cannot call value of non-function type '[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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM