我正在尝试检索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 = .....
}
}
}
有人可以告诉我怎么了吗?
答案 0 :(得分:2)
providerData
是FIRUser
检查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 = .....
}
}