From the course: Advanced iOS Development: Working with APIs

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Loading data a page at a time

Loading data a page at a time

- [Instructor] Okay so it's time to save our product's data into a page. And we can create a page result by setting the page number to the page parameter value that we received from the call to load products initially. And the result will simply be the product's data that we just parsed. So let's go ahead and save this in a product page variable. Now what we want to do ultimately is still just to pend the product page to a list of product pages. This let's us keep track of all the pages that we've collected so far. However it might be the case that load products was called multiple times for the same page. Which means we could end up with duplicate data in our product pages collection. So let's go ahead and try to guard that by simply thinking this out and we'll use a guard clause to help us out. So, if we have maybe a property that's called loadedProductPageNumbers, and it might be an aray of some sort so it might have this contains function on it. So to rephrase what we just wrote…

Contents