Should I use OutletCollections for setting delegate property of multiple textfields?

96 views Asked by At

Say, I've n textfields, now I have individual @IBOutlets for them. Generally, I'd set the delegate like following:

textfield1.delegate = self
textfield2.delegate = self
.
.
.
.
.
.
textfieldn.delegate = self

However, I can also use IBOutletCollection for the same.

so I can have something like the following:

for tf in textfields{
    tf.delegate = self
}

where textfields is [UITextFields], an array of textfields.

I wanna know how it affects the performance of the code? Kindly specify for smaller and larger sets separately(like when n = 3, n = 10). Further, what happens if I'm not using IBOutletCollection and just programmatically creating an array like the following. Would it impact the performance or would it be the same as before?

textfields = [textfield1,textfield2,textfield3,.......,textfieldn]

I understand that chances of having a larger n represents bad designing, but I'm just curious.

Thanks in advance.

0

There are 0 answers