Skip to content

Instantly share code, notes, and snippets.

@tobeiosdev
Last active May 4, 2016 22:08
Show Gist options
  • Save tobeiosdev/1ac87bfd4ed0bd33d35e21dd7b810c6e to your computer and use it in GitHub Desktop.
Save tobeiosdev/1ac87bfd4ed0bd33d35e21dd7b810c6e to your computer and use it in GitHub Desktop.
var testArray = [String]()
var initialLoad = true
override func viewDidLoad() {
DataService.ds.REF_TITLE.queryOrderedByChild("timestamp").observeEventType(.ChildAdded, withBlock: { snapshot in
let lastName = snapshot.key as String
print(snapshot.key)
self.testArray.insert(lastName, atIndex: 0)
self.countTitle.text = "\(self.testArray.count) posts"
})
DataService.ds.REF_TITLE.observeSingleEventOfType(.Value, withBlock: { snapshot in
if self.initialLoad == true {
self.tableView.reloadData()
self.initialLoad = false
}
})
}
@IBAction func refreshBtn_clicked(sender: AnyObject) {
tableView.setContentOffset(CGPointZero, animated: true)
self.tableView.reloadData()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment