Created
January 8, 2019 19:39
-
-
Save kreeger/f1ac4dd8ab5a41dc80d8d8561872d45e to your computer and use it in GitHub Desktop.
Example background execution 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
dataAccess.performInBackground { [weak self] context in | |
let pancake = context.create(Pancake.self, attributes: ["flavor": flavor, "radius": radius, "height": height]) | |
let error = context.persist() | |
DispatchQueue.main.async { | |
guard let self = self else { return } | |
let foregroundPancake = self.dataAccess.mainContext.object(ofType: Pancake.self, objectID: pancake.objectID) | |
completion(foregroundPancake, error) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment