Depends on what you want to do. If you just change the value, then yes, there is an easier way:
[[[self fetchedResultsController] fetchedObjects] setValue:someValue forKey:@"someKey"]
which will go through all the objects that set the value. This is a standard KVC operation. Note that this will expand memory, as each object will be implemented during mutation.
- , . . . , Core Data, .
, . , , reset , . , , , , . :
NSManagedObjectContext *moc = ...;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSInteger drainCounter = 0;
for (id object in [[self fetchedResultsController] fetchedObjects]) {
++drainCounter;
if (drainCounter = 100) {
BOOL success = [moc save:&error];
NSError *error = nil;
NSAssert2(!success && error, @"Error saving moc: %@\n%@", [error localizedDescription], [error userInfo]);
[moc reset];
[pool drain], pool = nil;
pool = [[NSAutoreleasePool alloc] init];
drainCounter = 0;
}
}
BOOL success = [moc save:&error];
NSError *error = nil;
NSAssert2(!success && error, @"Error saving moc: %@\n%@", [error localizedDescription], [error userInfo]);
[pool drain], pool = nil;
, !. 100 . , , .