i’m creating a bunch of textfields. i am stacking them vertical, so i use:
CGRectMake(193, ((i * 45) + 45), 240, 30)
then after each textbox is created, i increment i.
int i = 0
CGRect myRect = CGRectMake(193, ((i * 45) + 45), 240, 30)
UITextField *myTextField01 = [[UITextField alloc] initWithFrame:myRect];
//format and add to view text field
i++;
//create next text field
myRect = CGRectMake(193, ((i * 45) + 45), 240, 30) //can i get rid of this line?
UITextField *myTextField01 = [[UITextField alloc] initWithFrame:myRect];
//format and add to view text field
i++;
i need to reassign the myRect to get i updated to the value of 1.
is there a better way to do this so i don’t need to reassign myRect to get the update value of i?
CGRectis a struct, so you can increment the internal fields directly:I would also use a loop and some kind of container (probably
NSArray), but that’s a side topic;)