I am currently using the paradigm I'm about to describe below in my application and it works, so It's not a big problem; however, I would like to know if I'm breaking some kind of rule with this pattern.
I am using ARC.
I have an application which presents a modal viewController. It has a table view on it.
I then have an "add" button which allows me to enter some data into the table view.
Pressing add, pops up a little dialog box created from a UIView with many textFields. - Each textField is an instance variable.
I'm alloc initing the textField instance variables when my add method gets called.
My question is: Is it OK to call this add method on my viewController which instantiates the instance variables and uses them, and then later, call the same method again which would be calling alloc init on instance variables that were already allocd and inited the last time the method was called.
Thus calling alloc init on the same ivars without niling them first - i'm also using ARC?
Something like this pseudocode:
.h
@property UITextField *textField;
.m
@synthesize textField;
(void) someMethod {
textField = [[UITextField alloc] init]
[textField doSomethingElse]
}
LATER
Some method is called over and over again.
Should I instead alloc init all the textfields, and just add and remove them from my UIView in the add method?
Thanks, Regards, John