Hello developer.
I've a small problem
I've an array:
PHP Code:
NSMutableArray *my_array = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"f",@"g",nil]; //And a for cycle for(int i=0; i < [my_array count]; i++) { //If a write [myLabel setString:[my_array objectAtIndex:i]]; //myLabel text return is 0,1,2,e,f and no 1,2,3,f,g } //
Updating a label multiple times in a loop doesn't make sense - you'll only see the last value. If you run your code as-is, I'd expect to see just "g" - only the last item will wind up in the label.
If I run my modified code I see 1,2,3,f,g in the log, so your array is fine:
Code:
NSMutableArray *my_array = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"f",@"g",nil];
//And a for cycle
for(int i=0; i < [my_array count]; i++)
{
NSLog(@"item: %@",[my_array objectAtIndex:i]);
}
Are you modifying "i" somewhere else? Are you modifying the array somewhere else?
There is no setString: in UILabel, maybe just a typo..
Good point. Didn't notice that.
jhoncybpr, I don't know what setString or FontLaber is - you usually use setText: with UILabel. Do you get the right answers when you NSLog? then your array is okay and the problem is in setString.
jhoncybpr, I don't know what setString or FontLaber is - you usually use setText: with UILabel. Do you get the right answers when you NSLog? then your array is okay and the problem is in setString.