Created
January 8, 2019 19:39
-
-
Save kreeger/b00e97a7b636a68c28cb59fbefde5492 to your computer and use it in GitHub Desktop.
Example fetch code for the blog post "Flapjack" on O'Reilly's engineering blog.
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 every pancake. | |
let pancakes = dataAccess.mainContext.objects(ofType: Pancake.self) | |
// Get just the chocolate chip ones. | |
let pancakes = dataAccess.mainContext.objects(ofType: Pancake.self, attributes: ["flavor": "Chocolate Chip"]) | |
// Create your own. | |
let pancake = dataAccess.mainContext.create(Pancake.self, attributes: ["flavor": "Rhubarb"]) | |
// Save your changes. | |
let error = context.persist() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment