ios - How to load data for UITableView from an API with pagination? -


i have api , when send request alamofire returns me, example, 500 records! cannot take of , use it. instead of did pagination on api, /page/1, /page/2, etc.

but how can load data in uitableview? want show loading indicator when scroll uitableview, while data, , data partly, append main array. how can achieve this?

or there solution it? can advice me?

i searched lot it, of solutions in objective-c. found one: ios - how make tableview use paginated api output?

but did not understand answer completely. variables there, not know means

you need create uiactivityindicatorview , use scrollviewdidscroll(scrollview: uiscrollview) control data array

private let serialqueue = dispatch_queue_create("mainvcloadingqueue", dispatch_queue_serial)  override func scrollviewdidscroll(scrollview: uiscrollview) {     delegate?.maincollectionviewdidscroll(scrollview) }  func maincollectionviewdidscroll(scrollview: uiscrollview) {         dispatch_sync(serialqueue, {             if scrollview.contentsize.height - scrollview.contentoffset.y - scrollview.frame.height < 1000 {                 dispatch_async(globalmainqueue, {                     loadingindicator.startanimating()                     if !self.isloading {                         self.isloading = true                         self.itemdatamanager!.getmoreitem({ itemlist in                             self.rootview?.data = itemlist                             self.isloading = false                             loadingindicator.stopanimating()                         })                     }                 })             }         })     }  var data: yourdata? {     didset{         updateui()     } }  private func updateui(){     collectionview.datasource = data     collectionview.refresh() } 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -