Currently my database looks like this:
<posts>
- "1"
- "2"
- "3"
And that is also the order I'm retrieving and ordering this data to my iOS app using:
func getQuery() -> FIRDatabaseQuery {
let myTopPostsQuery = (ref.child("posts"))
return myTopPostsQuery
}
override func viewDidLoad() {
super.viewDidLoad()
self.ref = FIRDatabase.database().reference()
dataSource = FirebaseTableViewDataSource.init(query: getQuery(),prototypeReuseIdentifier: "Cellident", view: self.tableView)
dataSource?.populateCellWithBlock { (cell: UITableViewCell, obj: NSObject) -> Void in
let customCell = cell as! CustomCellTableViewCell
let snap = obj as! FIRDataSnapshot
let childString = snap.value as! [String : AnyObject]
customCell.textLabel.text = String(childString)}
}
tableView.dataSource = dataSource
tableView.delegate = self
}
And then obviously it gets displayed in the table from 1 to 3 in that same order. What I want to achieve is displaying it in the reversed order, such that the last element in the database gets displayed first, namely 3, 2 and then 1 as the last (furthest down) element in the table.
Haven't found anything in the docs about that yet, it's mostly about ordering it by a value. I guess that either I can let firebase retrieve it in a different order or populate the table cells reversed?