Table of Contents
CoreData is a great framework to generate persistence and caching mechanisms, but what if we decide to integrate it with the MVVM Pattern to guarantee legibility, scalability and re-usage? Here is a little tutorial to follow along.
You should have gone through "Tutorial-CoreData" to have some preliminary knowledge about CoreData and be able to go through this activity.
By the end of the tutorial you should be acquainted to combining the MVVM Pattern and CoreData in SwiftUI.
-
Clone the repo
git clone https://github.com/developer-academy-unina/Tutorial-CoreData-with-MVVM
-
Open the
.xcodeproj
file
Using both MVVM Pattern and Persistence is crucial for setting a very powerful structure for your app. In this tutorial you will move your first steps to master these powerful concepts.
- Here you will understand how to separate responsibilities, using a
PersistenceManager
to deal with the actual local storage and a ViewModel to exempt the View from directly manipulating data. - Saving the ManagedObjectContext in the ViewModel by using the
@escaping
closures to deal with the completion of a function. - How to CRUD Data: Create, read, update and delete CoreData’s entities.
You've found a bug in the source code, a mistake in the documentation or maybe you'd like a new feature? Take a look at GitHub Discussions to see if it's already being discussed. You can help us by submitting an issue on GitHub. Before you create an issue, make sure to search the issue archive -- your issue may have already been addressed!
Please try to create bug reports that are:
- Reproducible. Include steps to reproduce the problem.
- Specific. Include as much detail as possible: which version, what environment, etc.
- Unique. Do not duplicate existing opened issues.
- Scoped to a Single Bug. One bug per report.
Reach out to the maintainer at one of the following places:
- GitHub Discussions
- GitHub issues
- Contact a Mentor for any other help
The original setup of this repository is by Luca Palmese.
For a full list of all authors and contributors, see the contributors page.
This project is licensed under the MIT License.
See LICENSE for more information.