Last active
February 4, 2019 12:36
-
-
Save nicol3a/e55aa72acc2bfd24d22d04940b910d5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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