views:

56

answers:

1
NSMutableArray *array = [NSMutableArray arrayWithObjects:@"Hello World!", [NSURL URLWithString:@"http://www.apple.com"], nil];
for (id *object in array) {
 NSLog(@"Class name: %@", [object className]);
}

Given the above array of varying objects what is the proper way to fast enumerate thru them? Using the above code I do see my log statement properly, but Xcode does complain with the following message

Invalid receiver type 'id*' on my NSLog statement.

+10  A: 

That should be:

for (id object in array) {
// ...

That is because id already is a pointer, see the section on id in Apples The Objective-C Programming Language for details on it.

Georg Fritzsche