Beginning Core Data
Learn the basics of Core Data in this beginner series. You’ll learn how to model your data with attributes and relationships, save data using a context, display saved data in lists and much more, in both SwiftUI and UIKit! By Pasan Premaratne.
Who is this for?
Beginners with just a little bit of iOS and Swift experience. This course isn’t suited for intermediate or advanced developers. If that’s you, check out our intermediate or advanced video courses for more ways to level-up your developer skills!
Covered concepts
- Managed object models
- Managed object contexts
- Fetch requests and fetch results
- Sorting data with sort descriptors
- Filtering data with predicates
- Using fetched results controllers to handle data changes
- Storing large files as external data
Part 1: The Core Data Stack
What is Core Data? Find out how it is used to store data in your apps.
Take a high level tour of the Core Data stack and understand what Core Data is and isn't.
Understand how Core Data represents an app's data model using managed objects
Core Data needs to keep track of changes to the managed object model and it does this using a managed object context. Get a high level understanding of how a context is used in this episode.
Understand how the persistent store coordinator facilitates communication between the context and underlying data store.
Create a Core Data stack for use in the Reminders app!
Wrap up this section by reviewing what you've learned about the Core Data stack, and find out what's coming up in the next section.
Part 2: Saving and Fetching Reminders
Learn what an Entity is in the Core Data framework and how you can add attributes to model your data.
In this challenge complete the Reminder entity by adding attributes to define your data model
Understand what managed object subclasses are and how you can use them in code to represent your Core Data model.
Now that you have a Reminder class you can use learn how to populate it and save data to the persistent store.
Understand how to use @FetchRequest and associated types to display the saved Reminders in a list.
Learn how to sort fetched results by adding sort descriptors to your fetch requests.
Learn how to create predicates using NSPredicate to filter fetched results.
Understand how to create relationships between entities in your object graphs to make your data model richer.
Understand how to leverage the relationships in a model to display data without executing a fetch request.
Level up your knowledge of predicates by combining multiple using a compound predicate
In this challenge add functionality to add tags to Reminders by updating the data model.
In the second part of the challenge, update the user interface to display the tags you added in the last challenge!
Understand how to use transient properties to add functionality to your managed objects.
Wrap up this section by reviewing what you've learned about Core Data and SwiftUI, and find out what's coming up in the next section.
Part 3: Core Data and UIKit
Understand the differences between using Core Data in UIKit versus SwiftUI.
In this episode, configure your project to pass the managed object context around so you can save data.
Understand what a fetched results controller is and how you can use it to fetch lists you have saved.
Learn how to use the fetched results controller's delegate to inform you of changes to the context and handle it appropriately.
In this challenge modernize the view controllers to use diffable data sources in conjunction with fetch results controllers.
Understand the various types of delete rules you can specify when deleting managed object instances.
Now that you understand delete rules let's implement delete methods for the Reminders app.
Understand the difference between Transformable and Binary Data attributes and how you can save large files.
Wrap up this section by reviewing what you've learned in the course, and find out where to go next!