My hope is that this series has taught you that Core Data isn't as difficult as many developers believe it to be. Core Data isn't complex once you understand how the various pieces of the framework fit together.
In this episode, I'd like to discuss a concept that often confuses developers new to Core Data, faulting. Before I explain what faulting is, I want to show it to you.
CoreDataManager class is in charge of the Core Data stack of the application. It encapsulates the Core Data stack and only exposes the main managed object context to the rest of the application.
Because we updated the
CoreDataManager class in the previous episode, we need to make a few changes in the project.
It's time to refactor the
CoreDataManager class. Let me walk you through the changes we need to make. Don't worry, though, most of the implementation of the
CoreDataManager class remains unchanged.
We currently use one managed object context, which we created in the
CoreDataManager class. In the application, we pass the managed object context to the objects that need it. This works fine, but there will be times when one managed object context won't cut it.
The last feature I want to add is the ability to tag notes. This feature is interesting because of the Many-To-Many relationship of the Note and Tag entities. In this episode, you learn how to work with such a relationship.
In the previous episode, we exposed the root cause of the crash we ran into earlier. The solution is versioning the data model.
An application that grows and gains features also gains new requirements. The data model, for example, grows and changes. Core Data handles changes pretty well as long as you play by the rules of the framework.
In this episode, I'd like to add the ability to assign a color to a category. This makes it easier to visualize which category a note belongs to.