I found such code on this site:
- (NSArray *) valueForKey:(id)key {
NSMutableArray *retval = [NSMutableArray array];
for (NSObject *object in self) {
[retval addObject:[object valueForKey:key]];
}
return self;
}
Sorry for the newbie question, but I can’t figure out what is fast enumerated there, as self is just an object, not a collection.
Any class that conforms to the NSFastEnumeration protocol can be enumerated with the
insyntax. The code snippet you posted implies that the class also implements the-countByEnumeratingWithState:objects:count:method defined by the protocol, and that that method returns an array of NSObject instances to iterate over.