Given an array
NSArray *myArray = @[@"hello", @5, @[@6, @7, @8]];
for (NSNumber *myNumber in myArray)
{
NSLog (@"%@", myNumber);
}
Would the output of the log message be 5 or 5 6 7 8. ie. Does the for/in loop introspect top level objects in a dictionary/array or deeply inspect nested sets, arrays, dictionaries, etc..?
Edit
I realize I'm taking a lot of heat for this question so let me clarify what I was getting at. Yes you are all right, for-in fast enumeration does not perform introspection, but why not? If I'm specifically designating a type such as NSNumber or NSString, why doesn't the for in loop perform a kindOfClass method with the type you designated rather than casting an object as the incorrect type? In the example above, is it not intuitive that I would only be iterating over the NSNumbers in the array?
I suspect that the answer is performing introspection on each item in an array may negate the performance enhancements of fast enumeration? But could this not be solved with using id when we want dynamic typing and explicit types when we'd like to perform introspection?