As we have done throughout this book, we are going to create a Manager class. This class will be responsible for getting data in and out of Core Data. Let's get started:
- Right-click the Core Data folder in the Common folder and select New File.
- Inside the Choose a template for your new file screen, select iOS at the top, and then Cocoa Touch Class. Then, hit Next.
- In the options screen that appears, add the following:
New file:
-
- Class: CoreDataManager
- Subclass: NSObject
- Also create XIB: Unchecked
- Language: Swift
- Click Next and then Create.
When the file opens, under your import UIKit, add the following:
import CoreData
This import allows us to have access to the Core Data library. Next, inside the class definition, ...