100 Days of SwiftUI
2026-06-24
Project 10, part 3
Finishing up the basic app. Networking!!!
Checking for a valid address
- this validation is simply checking that the fields have data in them, not going to the USPS API to check for validity.
Not that I have any idea of how to actually use it
Preparing for checkout
- basically 2 parts: the UI and packaging the Order for sending to someplace.
- uses
Decimalinstead ofDouble(I think this is new?) which behind the scenes converts it to integers and does the math without rounding risk
Sending and receiving orders over the internet
- Using the
async / awaitlanguage we learned a couple days ago - Buttons don’t like waiting, so the action needs to be placed inside a task
- a site for testing URL requests https://reqres.in – free for low use
- however, you need an API key HWS forum post
- still free, but you need to have a login
- add to the URL Request
request.setValue("your-personal-api-key-from-reqres", forHTTPHeaderField: "x-api-key")
- we set up the
CodingKeys: CodingKeyenumeration again, but it cannot be used for calculated properties, such ascost.- That implies that the server needs to be able to do the calculation from the submitted order details, doesn’t it?


Tip
XCode regex uses $1 syntax for captured blocks