i need to add textfield text to NSMutable string when end of the textfield end.
for that i use the code
- (IBAction)my_textfield_editing {
if ([my_textfield.text length]!=0) {
[my_string appendString:my_textfield.text];
NSLog(@"mystring %@",my_string);
}
}
give this to textfield EditingDidEnd.
but i got some problem here.
for first editing it adds string as string1.
for second editing it adds string as string1string1,string2.
for third editing it adds string as string1string1,string2string1,string2,string3
i think it repeats with previous string.
i am trying placing my_string = NULL before adding it
if i use it always shows null.
how can i resolve it.
can any one help me.
Thank u in advance.
appendString:
method won't work if you assignNull
to aNSMutableString'
. In order to make it work, you have to initialize it with some default string. In your case an empty string (ie.,@""
). For example, you have to initialize the mutable string like the following.