Reputation: 15
I want that data which come from firebase have to be like in reverse, the last data must be up.
My code to retrieve data:
override func viewDidLoad() {
super.viewDidLoad()
isRead = false
tableView.delegate = self
tableView.dataSource = self
ref = Database.database().reference()
databaseHandle = ref?.child("Child").observe(.childAdded, with: { (snapshot) in
var post = snapshot.value as? String
if let actualPost = post{
self.postData.append(actualPost)
self.tableView.reloadData()
}
})
}
Upvotes: 0
Views: 31
Reputation: 100541
Instead of
self.postData.append(actualPost)
Use
self.postData.insert(actualPost,at:0)
BTW directly use if let actualPost = snapshot.value as? String {}
Upvotes: 1