Ok I have 8 labels and I want to loop through them but am having no luck.
This is what I have tried.
for (int i; i = 0; i < 10; i++)
{
double va = [varible1.text doubleValue] + i;
int j = 0 + I
label(j).text= [[NSString alloc]initWithFormat:@"%2.1f", va];
}
This errors out. My labels are named like this label0, label1, label2
Any help would be appreciated.
You should maybe add all your labels to a C array, probably in -viewDidLoad
(not entirely sure about the syntax)
and then access them like
By the way, I think you’re leaking memory here:
initWithFormat: will return a string with a retain count of 1. labels[i].text will retain that value again. You should release the string after setting the label’s text. I’d probably just autorelease it here:
or use stringWithFormat (which returns an autoreleased string):