I have this code now:
This is iOS
for(NSDictionary * dict in myMutableArray)
{
NSString * str = [dict objectForKey:@"MyStringKey"];
[sheet addButtonWithTitle:str];
}
I need to also have a for loop like this:
NSInteger *count = [myMutableArray count];
for (i = 0; i < count; i++) {
arrayVar = [myMutableArray objectAtIndex:i];
}
I need to kind of combine these. I am inserting a segment into a UISegmentedControl while getting the name from a for loop which is looping through the array getting nsdictionary which is retrieving a nsstring that I will put into the uisegmentedcontrol.
So bottom line is I need to merge these for loops so I get the name like I do from the first for loop while still getting the objectatindex like it is in the second for loop.
How would I do this? Thanks!
The second version you have will work just fine.
There is no way to access the index in the first version.
There is a newer syntax available if you like, that uses blocks:
The main benefit of blocks is they can use multiple cores in your device more effectively.