Skip to content

Instantly share code, notes, and snippets.

@congbo
Created September 5, 2015 03:00
Show Gist options
  • Save congbo/cb85a81911f93c68e5c8 to your computer and use it in GitHub Desktop.
Save congbo/cb85a81911f93c68e5c8 to your computer and use it in GitHub Desktop.
MagicalRecord enumerateObjectsUsingBlock
[MagicalRecord saveWithBlock:^(NSManagedObjectContext * localContext) {
NSArray * array = [CoopBoxStorage findAllWithPredicate:predicate inContext:localContext];
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL * stop) {
CoopBoxStorage * coopBoxStorage = obj;
[coopBoxStorage MR_deleteEntityInContext:localContext];
}];
} completion:^(BOOL success, NSError * error) {
if (success) {
DDLogInfo(@"CoopBoxStorage stored on database without errors");
} else {
if (error) {
DDLogError(@"CoopBoxStorage failed to stored on database with Error %@, %s, %d", [error localizedDescription], __FUNCTION__, __LINE__);
}
}
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment