Core Data might seem like a dry topic at first, but it’s so useful when building apps – you’ve 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 –
NSPredicate, for example, could do with some refinement, and
NSSet is never pleasant to deal with – but with a little work on our behalf this stops being a problem.
Perhaps the most important thing about Core Data 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 Core Data will do a great job of managing it for you.
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.
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 tasks require you to modify the
FilteredList view we made:
.beginsWith, then make that enum get resolved to a string inside the initializer.
FilteredListaccept an array of
SortDescriptorobjects to get used in its fetch request.
Hacking with Swift+ subscribers can get a complete video solution for this checkpoint here: Solution to Core Data. If you don’t already subscribe, you can start a free trial today.
Tip: If you’re using the generic version of
FilteredList, your sort descriptors are of type
SortDescriptor<T>. If you’re using the simpler, non-generic version, your sort descriptors are of type
SAVE 50% To celebrate WWDC23, all our books and bundles are half price, so you can take your Swift knowledge further without spending big! Get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn advanced design patterns, testing skills, and more.
Link copied to your pasteboard.