I assume that in each case you are listing a collection of objects, since only form C for(;;)allows you to list primitive types. The construct for(in)uses a protocol called NSFastEnumerationto fill the buffer with objects for use in future iterations and uses a cursor to track which object it connects to. This makes it faster than:
NSEnumerator *e = [collection objectEnumerator];
while (id o = [e nextObject]) {
}
, , :
for (NSInteger i=0; i < [collection count]; i++) {
id o = [collection objectAtIndex: i];
}
- [*]. for(in) , , 8 .
, [collection enumerateObjectsUsingBlock: ^(id obj, int idx, BOOL *stop){/*...*/}];, . , , , .
[*] - , , ; , , .