Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rahul-inspired-iosdeveloper/83f5ac5aa45be4d4d74fdd2e4c9c1657 to your computer and use it in GitHub Desktop.
Save rahul-inspired-iosdeveloper/83f5ac5aa45be4d4d74fdd2e4c9c1657 to your computer and use it in GitHub Desktop.
let privateMOC = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
privateMOC.parent = context
privateMOC.performAndWait {
//do some coredata stuff, but dont carry on beyond this block, until the code
//in this block has finished executed (sync, not async)
saveContext(forContext: privateMOC)
}
//now save the main context with the changes from the private context
saveContext(forContext: context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment