Use the following code to retrieve the NSmanagedObjectContext
from the default Coredata implementation:
import CoreData
var context: NSManagedObjectContext?
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
context = appDelegate.persistentContainer.viewContext
}