on my first Fetch request i’m doing this :
let dataStore = backendless.data.of(PEvents)
dataQuery.queryOptions.pageSize(5)
dataQuery.queryOptions.related = ["b_publisher"]
dataStore.find(dataQuery,..........
for loading next page i’m doing this :
self.fetchResults = result // here fetchResults is first Request's response
fetchResults.nextPageAsync( { (nextResult : BackendlessCollection!) in
the next method is working fine but related objects are nil here , how can i fix this ??
Hi Billion Bucks,
We cannot reproduce this issue with your app (0B313C9C-C1C8-4FD4-FFB7-B3D4FD88BE00)
Here the test code:
func basicPagingAsync() {
let startTime = NSDate()
let query = BackendlessDataQuery()
query.queryOptions.pageSize(5)
query.queryOptions.related = ["b_publisher"]
backendless.persistenceService.of(PEvents.self).find(
query,
response: { ( bc : BackendlessCollection!) -> () in
print("Total objects - \(bc.totalObjects)")
self.nextPageAsync(bc, startTime:startTime)
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
func nextPageAsync(bc: BackendlessCollection, startTime: NSDate) {
let size = bc.getCurrentPage().count
if size == 0 {
print("Total time (ms) - \(1000*NSDate().timeIntervalSinceDate(startTime))")
return
}
print("Loaded \(size) objects in the current page")
let currentPage = bc.getCurrentPage() as! [PEvents]
for event in currentPage {
if event.b_publisher != nil {
print(event.b_publisher?.email)
}
}
bc.nextPageAsync(
{ ( result : BackendlessCollection!) -> () in
self.nextPageAsync(result, startTime:startTime)
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
and on the first and next pages all PEvents objects have not nil b_publisher relation (we can see log message from line 33).
Please try this code, how it will work for you?
Regards,
Slava