100 Days of SwiftUI
2026-05-06
Project 1, part three
WeSplit: Wrap up
The project is complete, so let’s review what we learned, take a little test and then do some practice
Quiz: WeSplit review — 11/12
Challenges
- Add a header to the third section, saying “Amount per person”
This was pretty easy — hardest part was finding the right section. Section ("Amount per person") {...}
- Add another section showing the total amount for the check
This was tougher. We already calculate the total amount in the variable totalPerPerson but it turns out that computed variables can only return one thing. But I don’t want to recalculate the amount! So I turned totalPerPerson: Double into totals: [Double] and return an array return [totalCheck, amountPerPerson]. It’s unsatisfying to call out total[0] though.
- Change the tip percentage picker to show a new screen rather than using a segmented control, and give it a wider range of options – everything from 0% to 100%. Tip: use the range
0..<101for your range rather than a fixed array.
Easier, except I had to look up the pickerStyle (.pickerStyle(.navigationLink))
Commentary
This was a very simple app, and we were basically just copying what he said to do. The challenges were pretty straightforward, though I am looking a lot of stuff up.
The issues I had were around ranges that act like arrays. Maybe if I think of a “range” as a “list” then it might make sense? I dunno.
I see why there are a lot of tip-splitting apps!