Randy Randy - 1 year ago 81
Objective-C Question

Add text to UItextField without erasing old text

I have an

, and I want to display the content of an array in it.
So I tried something like that (and then I realised it obviously wouldn't have worked):

for (NSInteger i=0; i<myArray.count; i++) {
[self.myTextField setText:myArray[i] ];

So, as you may guess, this code just displays the last element of my array in my text field.

My question: is it possible to edit the content of a text field, without erasing the content already present ?

Thanks a lot for your answers !

Answer Source


[self.myTextField setText:[[self.myTextField text] stringByAppendingString:myArray[i]]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download