I currently have a firebase database with a lot of posts in it. The posts are displayed in a UITableViewController in custom cells.
The problem is that it loads all of the cells at once - this can take a lot of time when more posts are coming.
How can I make it load only 10 posts at a time, and load 10 more when scrolling to the bottom?
This is how I fetch my posts:
func startObersvingDB() {
FIRDatabase.database().reference().child("feed-items").observeEventType(.Value, withBlock: { (snapshot: FIRDataSnapshot) in
var newUpdates = [Sweet]()
for update in snapshot.children {
let updateObject = Sweet(snapshot: update as! FIRDataSnapshot)
newUpdates.append(updateObject)
}
self.updates = newUpdates.reverse()
self.tableView.reloadData()
}) { (error: NSError) in
print(error.description)
}
}