100 Days of SwiftUI Day 71

100 Days of SwiftUI – Day 71

Welcome to day 71 of the 100 Days of SwiftUI! Yesterday, we expanded on MapKit and the functionality it offers us and our users. Today, we’re looking into how to download data from Wikipedia for use in our app. Let’s dive in!

Downloading data from Wikipedia in SwiftUI

To make this whole app more useful, we’re going to modify our EditView screen so that it shows interesting places. After all, if visiting London is on your bucket list, you’d probably want some suggestions for things to see nearby. This might sound hard to do, but actually we can query Wikipedia using GPS coordinates, and it will send back a list of places that are nearby.

Hacking with Swift, Paul Hudson (@twostraws)

In essence, we’re going to fetch data from Wikipedia and then immediately show it to our users in the UI.

Sorting Wikipedia results

When the results from Wikipedia are returned to us, they are sorted by their page ID on Wikipedia itself, not by something we’ve defined in SwiftUI yet. This is not particularly useful for us, nor our users. To solve this, we’ll use a custom closure to sort the results in a way that makes sense and is useful to users.

Wrap up

And that’s it for day 71! Another short and easy day, but a very fun one nonetheless. It makes what we’ve learned really tangible when we’re actually using a huge resource like Wikipedia within our app to fetch data from and show in our UI. Tomorrow is the last day for this project, so time to recharge and get ready! Until then.

Darryl

Hi! My name is Darryl and this is my personal blog where I write about my journey as I learn programming! You'll also find articles about other things that interest me including games, tech and anime.

Post navigation

Leave a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

100 Days of SwiftUI – Day 78

100 Days of SwiftUI – Day 52

100 Days of SwiftUI – Day 7 – Functions

100 Days of SwiftUI – Day 64