This project includes solutions to the challenges.
- Our address fields are currently considered valid if they contain anything, even if it’s just only whitespace. Improve the validation to make sure a string of pure whitespace is invalid.
- If our call to
placeOrder()
fails – for example if there is no internet connection – show an informative alert for the user. To test this, try commenting out therequest.httpMethod = "POST"
line in your code, which should force the request to fail. - For a more challenging task, see if you can convert our data model from a class to a struct, then create an
ObservableObject
class wrapper around it that gets passed around. This will result in your class having one@Published
property, which is the data struct inside it, and should make supportingCodable
on the struct much easier.