Follow along at https://www.hackingwithswift.com/100/swiftui/60.
This day resolves around recapping the content covered while going through Projects 10-12 in the 100 Days of SwiftUI Challenge, and then implementing a challenge project.
From the description:
Use
URLSession
to download some JSON from the internet, useCodable
to convert it to Swift types, then useNavigationView
,List
, and more to display it to the user.
And regarding the data source:
As you can see, there is an array of people, and each person has an ID, name, age, email address, and more. They also have an array of tag strings, and an array of friends, where each friend has a name and ID.
How far you implement this is down to you, but at the very least you should:
- Fetch the data and parse it into User and Friend structs.
- Display a list of users with a little information about them.
- Create a detail view shown when a user is tapped, presenting more information about them.
Where things get more interesting is with their friends: if you really want to push your skills, think about how to show each user’s friends on the detail screen.
For a medium-sized challenge, show a little information about their friends right on the detail screen. For a bigger challenge, make each of those friends tappable to show their own detail view.
Honestly, though, I'm not that into listing random people's data -- so I hit up the SpaceX API to see if there was an opportunity to do some more-interesting-but-concordant stuff with rockets 🚀.
As it turns out, SpaceX missions
and the lists of payloads
delivered during a mission's many launches fits the mold of what we're going for here perfectly.
Alas, all project files can be found in this day's Project
folder.