【发布时间】:2016-08-09 21:21:55
【问题描述】:
所以我尝试从 Firebase 加载数据,而不是同时加载所有数据。我想加载前 20 个子节点,然后当我在 tableView 中向下滚动时,我想再加载 20 个,依此类推。
BASE_URL.child("names").queryOrderedByChild("time").observeEventType(.Value, withBlock: { snapshot in
self.names = []
if let snapshots = snapshot.children.allObjects as? [FIRDataSnapshot] {
for snap in snapshots {
if let namesDictionary = snap.value as? Dictionary<String, AnyObject> {
let key = snap.key
let name = Name(key: key, dictionary: nameDictionary)
self.names.insert(name, atIndex: 0)
}
}
}
dispatch_async(dispatch_get_main_queue(), {() -> Void in
self.tableView.reloadData()
})
})
在这之后我有我的 TableView - 委托和数据源
【问题讨论】:
标签: ios swift firebase firebase-realtime-database