I thought that I knew how to use fast enumeration, but there is something I don\'t understand about it. If I create three NSString
objects and three NSNum
I'm pretty sure that fast enumeration returns all objects in the array- all that you're doing in for (NSString *str in array)
is typecasting str
to an NSString
. In the body of the loop you need to check the class of the returned object to make sure that it is an NSString
.
for(NSString *str in array)
{
if([str isKindOfClass:[NSString class]])
NSLog(@"str : %@", str);
}