In the previous demo, we saw how we can use
URLSession to fetch data from an API in the form of a JSON response. In the demo, we printed the JSON response in the console. However, it doesn't work like that in real apps. In normal scenarios, we parse this JSON response and convert it to model objects, which are friendly enough and encapsulated so that they can be used directly in view controllers to update the UI or to do any logic. In this section, we will continue working on the same demo, but instead of printing out the JSON response in the console as we did earlier, we will parse and convert it to model objects and display them on the screen.
The API that we will use is from the
randomuser website. Its supports pagination, and you can check it from the following URL:
In the API, you will see that we can pass the
page parameter to indicate the page index and the
results parameter for page size; these two parameters...