Skip to content

Instantly share code, notes, and snippets.

View evanlaird's full-sized avatar

Evan Laird evanlaird

  • Burlington, VT
View GitHub Profile
@evanlaird
evanlaird / asyncsave.m
Last active August 29, 2015 13:58
Asynchronously save up the parent-child chain of NSManagedObjectContexts to disk
- (BOOL)saveToDiskAndShouldWait:(BOOL)wait {
__block BOOL success = NO;
// Give self time to save
[self performBlockAndWait:^{
success = [self saveOrLogError];
}];
NSManagedObjectContext *parent = [self parentContext];
if (parent) {
if (wait) {
[parent performBlockAndWait:^{