Created
September 5, 2015 03:00
-
-
Save congbo/cb85a81911f93c68e5c8 to your computer and use it in GitHub Desktop.
MagicalRecord enumerateObjectsUsingBlock
This file contains hidden or 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
[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