Skip to content

Instantly share code, notes, and snippets.

View andrehsouza's full-sized avatar

André Souza andrehsouza

View GitHub Profile
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
let managedContext = appDelegate.persistentContainer.viewContext
if let customer: Customer = NSEntityDescription.insertNewObject(forEntityName: "Customer", into: managedContext) as? Customer {
customer.name = "Mike"
//stuff
}
}
import UIKit
import CoreData
//MARK: - Core Data stack
class CoreDataStack: NSObject {
static let sharedInstance = CoreDataStack()
static let containerName = "CoreDataExample" //CoreDataExample.xcdatamodeld
private override init() {}