How to do it...

  1. Let's continue working in our demo to build our Todo app.
  2. Create a new Group in Xcode called Model to add the model classes inside.
  3. Create a new class called AbstractManager to work as a parent manager for the TasksListsManager and the TasksManager classes that we will create.
  4. Add the following code in the AbstractManager class:
      import UIKit 
      import CoreData 
      class AbstractManager: NSObject { 
          /// The managedObjectContext for core data. 
          lazy var managedObjectContext: NSManagedObjectContext = { 
              let app =
                UIApplication.shared.delegate as! AppDelegate 
              return app.persistentContainer.viewContext 
  1. Add a new class called TasksListManager with a subclass of AbstractManager. Add the following code in TasksListManager.swift

Get iOS Programming Cookbook 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.