fast-enumeration

fast enumeration for array containing different types of objects

If I have an NSMutableArray where I added objects of different classes (e.g. NSString, NSMutableString, NSProcessInfo, NSURL, NSMutableDictionary etc.) Now I want to fast enumerate this array, so I tried: for (id *element in mutableArray){ NSLog (@"Class Name: %@", [element class]); //do something else } I am getting a warning i...

Is fast enumeration considered bad form or is it generally accepted?

Just wondering, it seems like it works pretty well but I want to make sure I am using generally accepted coding practices and not get into bad habits. Thanks, Nick ...

Application not entering Fast Enumeration loop

after much debugging, I have determined that this code is ignoring the fast enumeration loop and blindly jumping to the end: -(void)loadOutAnnotations { NSLog(@"entering Annotation enumeration Loop"); iProspectFresno_LiteAppDelegate *appDelegate =(iProspectFresno_LiteAppDelegate *)[[UIApplication sharedApplication] delegate]; ...

fast enumeration on NSDictionary fails with "[Waypoint countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance ..."

Hello, I have my data in a NSDictionary object where the keys are CGPoints converted to NSValues and the objects are UIColors. Here's the method I'm using to return an object from the dictionary: - (UIColor*) getTemperatureColor2 { NSDictionary* temperatureColorMap = [Weather getTemperatureColorMap]; for(id key in temperatu...

Does fast enumeration in Objective-C guarantee the order of iteration?

Can I expect it to go from the start of an array to the end in order? Can't find anything in the docs about this. i.e. is for (id val in array) { NSLog(@"%@", val); } always going to print out the same as for (int i = 0; i < [array count]; ++i) { NSLog(@"%@", [array objectAtIndex:i]); } ...

Is Fast Enumeration messing with my text output?

Here I am iterating through an array of NSDictionary objects (inside the parsed JSON response of the EXCELLENT MapQuest directions API). I want to build up an HTML string to put into a UIWebView. My code says: for (NSDictionary *leg in legs ) { NSString *thisLeg = [NSString stringWithFormat:@"<br>%@ - %@", [leg valueForKey:@"narrat...

Iterating Through an NSArray

Can someone help me fix my code here. I am trying to do something simple iterate through the whole array that has NSString's in it convert them to NSIntegers and assign them to a NSInteger variable. for (NSInteger *itemF in myNSArray) { //WHERE "slotA" is an NSInteger and "itemF" is stored as an NSString and I wanna conver to NSI...

Objective c "for each" (fast enumeration) -- evaluation of collection?

It seems from experimentation that the collection expression is evaluated only once. Consider this example: static NSArray *a; - (NSArray *)fcn { if (a == nil) a = [NSArray arrayWithObjects:@"one", @"two", @"three", nil]; NSLog(@"called"); return a; } ... for (NSString *s in [self fcn]) NSLog(@"%@", s); The ...