0
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.

1
  • Xcode is the IDE, not the compiler. Currently, the compiler is GCC unless you've switched it to Clang. Commented Aug 23, 2010 at 20:23

1 Answer 1

10

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.