Created
June 26, 2012 13:52
-
-
Save tonyarnold/2995892 to your computer and use it in GitHub Desktop.
Deleting all entities in your NSManagedObjectContext using MagicalRecord
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
NSArray *allEntities = [NSManagedObjectModel MR_defaultManagedObjectModel].entities; | |
[allEntities enumerateObjectsUsingBlock:^(NSEntityDescription *entityDescription, NSUInteger idx, BOOL *stop) { | |
[NSClassFromString([entityDescription managedObjectClassName]) MR_truncateAll]; | |
}]; |
Thanks
thanks
Thanks
for everyone who likes copy-pasting as much as I do:
if let all = NSManagedObjectModel.mr_default().entities {
for entity in all {
_ = NSClassFromString(entity.managedObjectClassName)?.mr_truncateAll()
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks.