Hi
On my Core Data Entity "Book" i have a boolean property, 'wasViewed' (NSNumber numberWithBool) that tells me if the Book was "viewed".
I would like to implement a sort of "reset" this property for all my NSManagedObjects "Book". So that I can set them all to NO between sessions. I use an NSPredicate to retrieve all the Books like this:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"wasViewed == %@", [NSNumber numberWithBool:YES]];
// code for setting entity, request etc...
NSMutableArray *mutableFetchResults = [[[managedObjectContext executeFetchRequest:request error:&error] mutableCopy] autorelease];
This is working just fine, however, now I need to set up a loop, go through each Book object, something like this:
for(Book *b in mutableFetchResults) {
[b setWasViewed:NO]
}
Is there a way to perform an action on each element that fits the predicate instead of retrieving it?
So instead of executeFetchRequest
on a managedObjectContext
it could be
executeOperationOnFetchRequestResults
or something along those lines.
Thanks for any input given:)