I want to do a for loop (i am now going to try to implement a table view but am still curious) How can I increment the value of 'itemListText1' so it is 'itemListText%i'?
HTML Code:
//=======( create or destroy the text in field %i )=======
if ([mainDelegate.personArray count] == 1) {
itemListText1.text = [NSString stringWithFormat:@"%@ - %@", [[mainDelegate.personArray objectAtIndex:0] itemTitle], [[mainDelegate.personArray objectAtIndex:0] itemAddtl]];
itemListText2.text = [NSString stringWithFormat:@""];
//=========( corresponding delete buttons )==========
remove1Button.hidden = YES;
remove2Button.hidden = NO;
}
im sure its dead simple.. just create a variable and assign?
Note sure exactly what "itemListText1" and "itemListText2", etc. are, but you could potentially have set your class up to use arrays instead of individual items.
itemListText[0], itemListText[1], etc.
There's nothing that says that the references to screen objects, etc. can't be held in arrays, although that might require creating the screen programmatically as opposed to using IB.
Note sure exactly what "itemListText1" and "itemListText2" are
these are labels.
so you are saying write all the code for drwaing a label and store that code in an array replacing variable in the arraycode with varibles created on the fly?
these are labels.
so you are saying write all the code for drwaing a label and store that code in an array replacing variable in the arraycode with varibles created on the fly?
I guess I don't understand enough of exactly what it is that you're trying to do.
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...
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...
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:
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?
Or am I just missing something fundamental in what you're trying to do?
Its exactly what im trying to do and more to the point you touched on something I hadnt thought of. and that is to create the elements on the fly in code as opposed to in IB.
This makes more sense, even though its kinda simple to make buttons in IB and make connections. Im more of a visual kinda guy.
thanks for the suggestions and cleaner code than what was recently over 60 lines! It made me queasy just typing all that junk in knowing there was a better solution.