I am tying to add the values from an array to a number of text boxes in my view. it is possible for me to make it work by implementing
a1.text=[arrayName objectAtIndex:1];
Similarly i am having a1, a2, a3,... a45,... a60,...开发者_C百科 upto a99
Here "a1" is the outlet of a particular textfield. what i need is that, i have a plenty of controls on my screen. so its not possible for me to add each and every line. is there any way to add the values from the array to the corresponding textboxes.
what i need is to have a loop which will recursively add the values from the array to the textboxes. which implements the following manually written code
a1.text = [arrayName objectAtIndex:1];
a1.text = [arrayName objectAtIndex:2];
...........
a99.text = [arrayName objectAtIndex:99];
can any one help me please...
Thanks in advance, Shibin
When you create you controls (e.g. textfields) set their tag
property to a value that can later be used to determine an index for corresponding value in your array:
for (int index = startTag; index <= endTag; ++index){
UITextField* field = (UITextField*)[view viewWithTag:index]; // or [view viewWithTag:index + someValue];
field.text = [arrayName objectAtIndex:index];
}
精彩评论