Actually, I think you do not have to loop through your objects.
NSUInteger checked = [(NSNumber*)[imagesController.arrangedObjects
valueForKeyPath:@"@sum.boolProperty"] integerValue];
This is sort of a hack because a BOOL
will be interpreted as 0 or 1.
The semantically more correct way is.
NSUInteger checked = [imagesController.arrangedObjects
filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:
@"boolProperty == %@", @YES]].count;
This is assuming that you have an array (arrangedObjects
) which contains instances of NSManagedObject
(or subclass thereof). The objects have a property called boolProperty
of type NSNumber
(which is the standard wrapper for BOOL values in managed objects). When a row is displayed, it is marked as checked if this boolProperty
is @YES
. If you change the checkmark (e.g. by selecting the row), the model should be updated: the appropriate managed object should be retrieved and the boolProperty
toggled.