I'm trying to insert a UILabel into an array and then display it in a certain point on the screen. Using a for loop, I'm counting the amount of elements in a array, and for every element, I want to create a label. This is only producing one label at the moment (the first element in the array).
int y = 260;
for(int i = 0; i < _jsonArray.count; i ++)
{
NSNumber *one = [[_jsonArray objectAtIndex:i] objectForKey:@"amount"];
NSString *name = [[_jsonArray objectAtIndex:i] objectForKey:@"name"];
UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(10, y, 200, 40)];
[myLabel setBackgroundColor:[UIColor clearColor]];
[myLabel setText:name];
[_slices addObject:one];
[[self view] addSubview:myLabel];
y=y+20;
}
Any help would be much appreciated!