O'Reilly logo

iOS Programming Cookbook by Hossam Ghareeb

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing JSON data

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.

Getting ready

The API that we will use is from the randomuser website. Its supports ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required