Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Get context
let context: NSManagedObjectContext = ...
// Create
let eventToInsert = Event(title: "I went to the hairdresser", date: Date())
EventManagedObject.insert(object: eventToInsert, with: context)
// Read
let events: [Event] = EventManagedObject.fetchAll(from: context)
// Update
let eventToUpdate = events[0] = Date()
EventManagedObject.update(object: eventToUpdate, with: context)
// Delete
let eventToDelete = events[1]
EventManagedObject.delete(eventToDelete, with: context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment