counter = [myArray count];
for (i = 0 ; i < count ; i++) {
[[anotherArray objectAtIndex:i] setTitle:[myArray objectAtIndex:i]];
}
I would like to do it the objective C 2.0 way but can’t seem to find how to access the index ‘i’ (if that’s possible anyway).
for (NSString *myString in myArray) {
[[anotherArray objectAtIndex:i] setTitle: myString];
}
(Please forgive any typos; I’m currently not behind my Mac so this is out of my head.)
To do this you have to keep track of the index yourself:
Maybe in this case an old-fashioned
forloop with an index is the better choice though. Unless you are trying to use fast enumeration for performance reasons here.But it would be probably even better to restructure the code so that you don’t have to copy the strings from
myArrayto the title property of the objects inanotherArraymanually.