I know this question has been asked many times. You can convert string to integer in this two ways:
[myString intValue]
which returns a "C" type or [myString integerValue]
which returns NSInteger.
But my requirement looks like this:
int route1 = 12,route2 = 5,route3 = 6;
for (int j = 1; j < 4; j++) {
int route = [[NSString stringWithFormat:@"route%i",j] integerValue];
//do something using the route
}
I need the route variable to take the values of the different routes depending on the value of variable j.
How do i do it? Need some guidance on this.