Core Data manager 

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:

  1. Right-click the Core Data folder in the Common folder and select New File.
  2. Inside the Choose a template for your new file screen, select iOS at the top, and then Cocoa Touch Class. Then, hit Next.
  3. In the options screen that appears, add the following:

New file:

    • Class: CoreDataManager
    • Subclass: NSObject
    • Also create XIB: Unchecked
    • Language: Swift
  1. 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, ...

Get iOS 12 Programming for Beginners - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.