Lecture: URLSession and Codable
Implementation of Codable protocol and URLSession to decode JSON data from PokeAPI to display and utilize in a master-detail application.
A majority of Lambda students find themselves in a lecture being taught one particular way to utilize a concept, but will quickly be assigned a project where the use case changes and they're challenged in tweaking what they know to achieve some sort of other functionality. In this particular lecture, I challenged the students to implement a networking method in tandem with a search bar, so that a URLSession data task would be responsive to a search term passed in by the user.
We used PokeAPI to pull down specific properties about a searched Pokemon from the database to display in our app. Once a Pokemon had been searched, a search view controller displayed a Pokemon's sprite, type(s), abilities, and identification number. The user could then save the Pokemon to their "team" in a table view controller, and then they could select a cell where a Pokemon was listed to segue to a detail view controller where the information would be accessible again.
The students got some excellent practice decoding JSON to fit their custom model objects and saw multiple cases of common bugs/errors developers encounter when attempting to pull data from an API. I received a lot of feedback from the students following the lesson, mentioning how excited they were to practice these concepts with other APIs that they were interested in. I'm learning that there's really no better way to learn than to attempt to help others understand.
The repository for the completed project can be found here.