Skip to content

Instantly share code, notes, and snippets.

Embed
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]
eventToUpdate.date = 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
You can’t perform that action at this time.