Backendless Support
 
Completed

Load ( Retrive ) Large Data objects with paging Backendless V4 (ios,swift)

Hi,

I've been locking for so long time for a solution for this problem in the backendless documents did't found an 100% solution for my issue

AND i figure it out

So I want to share my methods for any one maybe it will help !

Backendless Devs and community users were very helpful to me

AND this at least that I can do :D

  1. @objcMembers

    class Prize : NSObject {

    var objectId : String?

    var title : String?

    }

  2. func fetchPrizes() {

    let queryBuilder = DataQueryBuilder()

    queryBuilder!.setPageSize(100).setOffset(0)

    let dataStore = backendless.data.of(Prize().ofClass())

    dataStore?.find(queryBuilder,

    response: {

    (result) -> () in

    let res = result as! [Prize]

    for p in res {

    print("Result: \(String(describing: p.title))")

    }

    self.fetchPrizesNextPage(queryBuilder: queryBuilder!)

    },

    error: {

    (fault : Fault?) -> () in

    print("Server reported an error: \(String(describing: fault))")

    })

    }

    func fetchPrizesNextPage(queryBuilder: DataQueryBuilder) {

    queryBuilder.prepareNextPage()

    let dataStore = self.backendless.data.of(Prize().ofClass())

    dataStore?.find(queryBuilder,

    response: {

    (result) -> () in

    let res = result as! [Prize]

    if res.count > 0 {

    for p in res {

    print("Result: \(String(describing: p.title))")

    }

    self.fetchPrizesNextPage(queryBuilder: queryBuilder)

    }

    },

    error: {

    (fault : Fault?) -> () in

    print("Server reported an error: \(String(describing: fault))")

    })

    }

Leave a Comment

Comments (1)

photo
1

Hi,

Thanks for sharing, Nasser! I'll resolve this solution as 'completed'

Best regards,

Anton