我正在尝试在 JSON 结构中创建一个名为 USERSLIST
的新路径!它将包含在我的 firebase 应用程序中创建帐户的用户列表。在我的 JSON 中,它必须如下所示:
USERSLIST:
- simpleLogin6 : aa@gmail.com
- simpleLogin9 : bb@gmail.com
它应该将创建的帐户的 uid
作为键,将电子邮件作为值。
我写了这段代码:
var usersList = [self.ref.authData.uid : authData.providerData["email"] as? NSString as? String,]
self.ref.childByAppendingPath("userList").childByAutoId().setValue(usersList)
但它在 setValue
行代码中显示了一个错误:
type [String: String] does not conform to protocol 'AnyObject'
最佳答案
var userList = [String:String]()
if let strEmail = authData.providerData["email"] {
usersList[self.ref.authData.uid] = strEmail as! String
}
关于ios - 类型[字符串: String] does not conform to protocol 'AnyObject' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32476448/