100 Days of SwiftUI
2026-07-21
Project 14, part 1
Bucket List
In this project we’re going to build an app that lets the user build a private list of places on the map that they intend to visit one day, add a description for that place, look up interesting places that are nearby, and save it all to the iOS storage for later.
Adding conformance to Comparable for custom types
Protocols and protocol extensions help us not have to worry about the fine details of stuff like, let values = [1, 5, 3, 6, 2, 9].sorted() returns [1, 2, 3, 5, 6, 9]
Adding Comparable conformance to the definition of a Struct makes it possible to sort things other than integers. In addition, you have to add something like this:
static func <(lhs: User, rhs: User) -> Bool {
lhs.lastName < rhs.lastName
}which looks to me like you’re redefining < for your User items. Ah yes, it’s called operator overloading, and it is probably helpful until it’s not.
You can then use the “normal” .sorted() modifier where Users are, ahem, used.
However, as written, it can’t handle if lhs == rhs so you need another protocol called Equatable (which he doesn’t detail in the video).
Also, how to do multiple sorting? (a quick glance at the internet suggests Moar Code is needed)
from this awesome repoWriting data to the documents directory
For this app, UserDefaults isn’t the right choice.
All apps have storage space — but they are sandboxed, so you need to use URL.documentsDirectory
To write, you need 2 bits: the URL and an array of options such as
.atomic— completes the whole write before it can be read again.completeFileProtection— encrypts the file so it can’t be read unless the device is unlocked
Switching view states with enums


Sometimes I think I’m only keeping up with this to see the puppers…
You can define views outside of ContentView then use an enum and some logic within it to say what to show. Also using Switch with enum ensures you update all cases if you add more or remove some (unlike an if...else)