@IBAction func addPost(_ sender: Any) {
ref?.child("Posts").childByAutoId().setValue(titleText.text)
}
如果我想在帖子中添加小节而不只是标题怎么办?比如日期、作者等
最佳答案
创建一个常规 Swift dictionary ,设置所需的属性,然后使用与上述相同的语法调用 setValue
。
例如:
let ref: FIRDatabaseReference = ...
let post = [
"title": "Incompleteness Theorem",
"author": "Kurt Gödel",
"date": "1931"
]
ref.child("Posts").childByAutoId().setValue(post)
关于ios - 如何使用 Swift 在 Firebase 数据库中设置多个值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43358188/