-4

This is my array

 var docData: [String: Any] = [
             "timestamp":Int64(Date().timeIntervalSince1970 * 1000),
             "photo": photo_uri,
             "name": name.text ?? "
             ]

I would like to add the next item into the array ["email": email.text ?? ""]

The following does not work

docData += ["email": email.text ?? ""]
Simon Ho
  • 588
  • 1
  • 8
  • 21

1 Answers1

3

You didn't create an array... you created a dictionary. In which case you would set the key to the value. A dictionary is a collection of key and value pairs.

docData["email"] = email.text ?? ""
ColdLogic
  • 7,206
  • 1
  • 28
  • 46