Hi I'm sorry for asking this on the mail list but Im at my wits end Ive been
stuck on this for two days and I can not seem to get paging working using the
apigee iOS sdks.
Ive added the code snippet below, Ive tried the sample collection application
in the sdks but it two is not working it returns the same ten entities each
time even when you click on the paging button Ive tried the sample collection
app with my collection that has 3000 entities in it . as you can see below Ive
got a UITable view and Im trying to page the data so the user get to the last
row if their is a next page It then fetches the next page of entities but all I
keep getting it 100's of row of the same ten entities so if some can see if Im
doing some thing wrong .. Please help Ive going crazy of this not work as I can
not debug the fault and Ive alway thought I was a very good iOS programming.
-(void)fetchCollection {
if(self.cursor == nil){
self.collection = [self.dataClient getCollection:@"shops"];
// self.cursor = [self.collection cursor];
do {
Job *job = [[Job alloc] initWithEntity:[self.collection
getNextEntity]];
[self.jobsArray addObject:job];
} while ([self.collection hasNextEntity]);
self.cursor = [self.collection cursor];
[self.tableView reloadData];
}
if (self.cursor != nil) {
if([self.collection hasNextPage]) {
[self.collection getNextPage];
[self.collection resetEntityPointer];
/// this was just some debuging.
// ApigeeClientResponse *res = [self.collection getNextPage];
// NSLog(@"count: %lu", (unsigned long)res.entityCount);
// NSArray *array = res.response[@"entities"];
// for (NSMutableDictionary *job in array) {
// Job *tmp = [[Job alloc] initWithDict:job];
// if(![self.jobsArray containsObject:tmp]){
// [self.jobsArray addObject:tmp];
// }
// }
while ([self.collection hasNextEntity]){
Job *tmp = [[Job alloc] initWithEntity:[self.collection
getNextEntity]];
// if(![self.jobsArray containsObject:tmp]){
[self.jobsArray addObject:tmp];
// }
} ;
[self.tableView reloadData];
}
}
}