How to run the fast enumeration like for loop?

79 Views Asked by At

In for loop we can simply define print data between 0 to 5 . Like this how we can define in Fast Enumeration?

for(int i=0;i<5;i++)
{ 
  NSLog(@"for loop");
}
1

There are 1 best solutions below

0
ChenSmile On BEST ANSWER

Fast Enumeration works for collection like

-NSSet

-NSArray

-NSDictionary

-NSMutableSet

-NSMutableArray

-NSMutableDictionary

NSArray *array = [[NSArray alloc]
initWithObjects:@"string1", @"string2",@"string3",nil];
for(NSString *aString in array)
{
  NSLog(@"Value: %@",aString);
}