【发布时间】:2019-03-17 07:13:25
【问题描述】:
我正在尝试为 Firebase 的数据库创建帖子。结构有点复杂。结构的 JSON 格式是这样的:
{
"wordList":[{"category":"Drink",
"category_id":"1",
"words":["Water","Tea"]},
{"category":"Food Item",
"category_id":"2",
"words":["Food","Burger"]}]
}
这是我用 Swift 写的:
func addWords() {
newRef = Database.database().reference().child("wordList")
let word = wordTextField.text
var addWordPost : [{String : AnyObject, Int : AnyObject, [String] : NSArray}]
}
任何帮助将不胜感激!非常感谢!
【问题讨论】:
-
尝试声明这个
[String: [[String: Any]]],不能在swift中使用{} -
嗨@a.masri 我希望 {} 之间的部分成为字典。我应该使用什么?
-
使用
[ ]这是一本字典读这个developer.apple.com/documentation/swift/dictionary
标签: swift database xcode firebase data-structures