UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

Bookworm: Wrap up

Paul Hudson    @twostraws   

Congratulations on finishing another SwiftUI project! With technologies like SwiftData at your side, you’re now capable of building some serious apps that interact with the user and – most importantly – remember what they entered. Although we only scratched the surface or SwiftData, it’s capable of a lot more and I expect Apple to keep expanding the link between SwiftData and SwiftUI in future updates. In the meantime, the very next project focuses deeply on SwiftData – there’s lots to explore!

As for the other things you learned, you’ve now even more of SwiftUI’s property wrappers, and I hope you’re getting a sense for which one to choose and when. @Binding is particularly useful when building custom UI components, because its ability to share data between views is just so useful.

There’s one last thing I’d like to leave you with, and it’s something you might not even have noticed. When we built a star rating component, we created something that became a user-interactive control just like Button and Slider. However, we didn’t stop to consider how it works with accessibility and that’s a problem: Button, Slider, and others work great of the box, but as soon as we start creating our own components we need to step in and do that work ourselves.

Building apps that are accessible for everyone is something everyone needs to take seriously, which is why I’ve dedicated a whole technique project to it in the future – we’re going to be looking back at the previous projects we’ve made and seeing how we can improve them.

Anyway, first things first – you have a new review and some challenges. Good luck!

Review what you learned

Anyone can sit through a tutorial, but it takes actual work to remember what was taught. It’s my job to make sure you take as much from these tutorials as possible, so I’ve prepared a short review to help you check your learning.

Click here to review what you learned in this project.

Challenge

One of the best ways to learn is to write your own code as often as possible, so here are three ways you should try extending this app to make sure you fully understand what’s going on.

  1. Right now it’s possible to select no title, author, or genre for books, which causes a problem for the detail view. Please fix this, either by forcing defaults, validating the form, or showing a default picture for unknown genres – you can choose.
  2. Modify ContentView so that books rated as 1 star are highlighted somehow, such as having their name shown in red.
  3. Add a new “date” attribute to the Book class, assigning Date.now to it so it gets the current date and time, then format that nicely somewhere in DetailView.

Hacking with Swift+ subscribers can get a complete video solution for this checkpoint here: Solution to Bookworm. If you don’t already subscribe, you can start a free trial today.

TAKE YOUR SKILLS TO THE NEXT LEVEL If you like Hacking with Swift, you'll love Hacking with Swift+ – it's my premium service where you can learn advanced Swift and SwiftUI, functional programming, algorithms, and more. Plus it comes with stacks of benefits, including monthly live streams, downloadable projects, a 20% discount on all books, and free gifts!

Find out more

Sponsor Hacking with Swift and reach the world's largest Swift community!

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Average rating: 4.7/5

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.