I have a table view controller that is fetching objects from a database hosted by parse.com. At the moment, I have the view controller fetch all the objects in the database for storage in an array. Right now, there are 100 objects in the database, and what I would like to do, is have the table view controller fetch 20 of those objects and display them, then have it fetch and display 20 more when the table scrolls to the bottom.
Here is my init method:
- (id)initWithStyle:(UITableViewStyle)style{
self = [super initWithStyle:style];
if (self) {
//create the array, set the table view size, then populate it.
listings = [[NSMutableArray alloc] init];
[self populateArrayWithListings];
}
return self;
}
[self populateArrayWithListings]; simply fills the array listings with the 100 objects in the database. I have this method to detect when the table view controller is scrolled to at the bottom:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.contentOffset.y + scrollView.bounds.size.height > scrollView.contentSize.height * 0.9) {
}
}
Question is, what should I put inside those brackets to have it fetch the next 20 objects in the database?
limitandskip(from the Query Contraints section in the Parse iOS Docs?limitand was wondering how I would be able to implement it. The only thing I could think of was to increase the limit when needed and "re-query" the objects, but that seemed inefficient to me. Is it?