简体   繁体   中英

type [String: String] does not conform to protocol 'AnyObject'

I am trying to create a new path called USERSLIST in my JSON structure! it will have the list of users that have created account in my firebase app. and in my JSON it must look like this :

USERSLIST:

  • simpleLogin6 : aa@gmail.com
  • simpleLogin9 : bb@gmail.com

it should have the uid of the account created as the key and email as the value.

I wrote this code :

var usersList = [self.ref.authData.uid : authData.providerData["email"] as? NSString as? String,]
self.ref.childByAppendingPath("userList").childByAutoId().setValue(usersList)

But it shows an error in the setValue line code that :

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

}

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