From the course: iOS Lean Controllers: 1 Setup, Persistent Data, and Implementation

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Implementing Core Data manager

Implementing Core Data manager

- [Instructor] All right, welcome back. So let's start with our first task, which is moving all the initialization code for our CoreData, which is initializeCoreDataStack, to somewhere else, not inside the ShoppingListTableViewController. We can move this. We can create a separate class and move all the initialization code for the CoreData into that class. So let's go ahead and create a new class. I'm gonna add a new file, and I'm just gonna select Swift File, Next, and I'm just gonna say CoreDataManager, and go ahead and Create that. Now I can go ahead and say okay, import CoreData, because I will be using CoreData. We will say CoreDataManager. Now the purpose of CoreDataManager would be to initializeCoreDataStack, and also to give us access to the managedObjectContext, which is responsible, which is everything that's required, if you want to use CoreData. It will have just a one method initializeCoreDataStack. Let's go ahead and Build it. Everything works okay right now. Now the…

Contents