For example, say I have an NSArray
that contains a bunch of NSString
objects:
NSArray *games = [NSArray arrayWithObjects:@"Space Invaders", @"Dig Dug", @"Galaga", nil];
What are the pros and cons of doing this:
for (id object in games) {
NSLog(@"The name of the game is: %@", object);
NSLog(@"The name is %d characters long.", [object length]);
// Do some other stuff...
}
versus:
for (NSString *name in games) {
NSLog(@"The name of the game is: %@", name);
NSLog(@"The name is %d characters long.", [name length]);
// Do some other stuff...
}