Quote:
Originally Posted by roberthuttinger
so if i have an array that has 1 item in it, it will load the label with the text from a arrayItem[1] and show the delete button, and there is no info after that . so what id like to do is a for statement...
HTML Code:
for(i=0; i=arrayItems.count;i++) {
itemListText [###how do I increment this?###].text = [NSString stringWithFormat:@"%@ - %@", [[mainDelegate.personArray objectAtIndex:0] itemTitle], [[mainDelegate.personArray objectAtIndex:0] itemAddtl]];
remove2Button.hidden = NO;
}
How can I make the number of the label at the end a variable on the fly?
for example:
itemListText1
itemListText2
itemListText3 etc
rob
|
So what's wrong with making "itemListText" an array (i.e. itemListText[3] instead of itemListText1, itemListText2 and itemListText3), making removeButton and array (i.e. removeButton[3] instead of remove1Button, remove2Button and remove3Button) and then doing:
Code:
for(i=0; i=arrayItems.count;i++) {
itemListText[i].text = [NSString stringWithFormat:@"%@ - %@", [[mainDelegate.personArray objectAtIndex:0] itemTitle], [[mainDelegate.personArray objectAtIndex:0] itemAddtl]];
removeButton[i].hidden = NO;
}
About the only issue I can think of is that you probably have to create the various items, buttons, etc. programmatically instead of creating them in InterfaceBuilder (since IB won't be able to inject into an array, I suspect) but that isn't hard. But that may actually be a good thing, since it would allow you to create the number of objects that match the number of items in your array, as opposed to having a fixed number.
Or am I just missing something fundamental in what you're trying to do?