Theoretically, you can iterate through all entity descriptions in the managed object model, create a query for them without predicates for them, then iterate over all returned objects and perform some updating. Example:
// Given some NSManagedObjectContext *context NSManagedObjectModel *model = [[context persistentStoreCoordinator] managedObjectModel]; for(NSEntityDescription *entity in [model entities]) { NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entity]; NSError *error; NSArray *results = [context executeFetchRequest:request error:&error]; // Error-checking here... for(NSManagedObject *object in results) { // Do your updates here } }
Note that you can bring NSManagedObjects returned as needed by testing for equality of classes (using isKindOfClass: or a method associated with it) or by determining which class is the current entity (using the managedObjectClassName property on an entity in combination with method NSClassWithName() ).
source share