@IBAction func addPost(_ sender: Any) {
ref?.child("Posts").childByAutoId().setValue(titleText.text)
}
What if I wanted to add subsections to post instead of just the title. Like date, authors, etc.
Create a regular Swift dictionary, set the desired properties, and then call setValue using the same syntax as above.
For instance:
let ref: FIRDatabaseReference = ...
let post = [
"title": "Incompleteness Theorem",
"author": "Kurt Gödel",
"date": "1931"
]
ref.child("Posts").childByAutoId().setValue(post)