Skip to main content

Day 59

About 2 minSwiftcrashcoursepaul-hudsonswiftswiftuihacking-with-swiftxcodeappstore

Day 59 ๊ด€๋ จ


Project 12, part 3

100 Days of SwiftUI - Day 59

Project 12, part 3

Are you ready for some more challenges?

American singer and songwriter Christina Grimmie once said, โ€œpeople aren't born strong; People grow stronger little by little, encountering difficult situations, learning not to run from them.โ€ The same is absolutely true of good coders: thereโ€™s no magic switch that gets flicked when youโ€™ve been reading books for a year, but instead your skills grow slowly over time as you face โ€“ and solve โ€“ increasingly hard problems.

I keep encouraging you to tackle these problems because writing your own code, and finding your own solutions, matters. At first there will often be some blank page syndrome โ€“ where you stare blankly at the screen, not knowing where to start. But thatโ€™s OK, and in fact itโ€™s to be expected. The more you practice the more adept youโ€™ll become at figuring out solutions for yourself, and today is another step towards that goal.

Today you should work through the wrap up chapter for project 12, complete its review, then work through all three of its challenges.

SwiftData: Wrap up

SwiftData: Wrap up
100 Days of SwiftUI - Day 59 - SwiftData: Wrap up

SwiftData: Wrap up

Although we've only really scratched the surface of what SwiftData can do, youโ€™ve still seen how it can add, delete, sort, filter, and more, all with relatively simple code. Yes, a few parts are a little murky in Swift โ€“ #Predicate, for example, can take some getting used to โ€“ but as long as you're careful you should be fine.

Perhaps the most important thing about SwiftData is that itโ€™s guaranteed to be there for all apps, on all of Appleโ€™s platforms. This means you can use it regardless of your needs: maybe itโ€™s for saving important data, maybe itโ€™s just a cache of content you downloaded; it doesnโ€™t matter, because SwiftData will do a great job of managing it for you.

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.open in new window

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.

All three of these challenges relate to you upgrade project 7, iExpense:

  1. Start by upgrading it to use SwiftData.
  2. Add a customizable sort order option: by name or by amount.
  3. Add a filter option to show all expenses, just personal expenses, or just business expenses.