Possible Duplicate:
Objective-c create variables in a loop
I have 10 UILabels, for the sake of simplicity let it be label0, label1, …, label9. Now, I’m implementing a loop and I need to access appropriate label from appropriate loop cycle:
for (int i=0; i<10; i++){
label"i".text = "value of label i";
}
I need to construct variable name by binding loop cycle variable value to it. Any suggestions?
For every
UILabelyou can keep atag.tagis anNSInteger.So it could essentially be your index number itself…
You can access the labels by calling
viewWithTag:on a parentUIView.