ios - textFieldDidEndEditing not recognising text in textfields correctly -


i trying detect change in text in textfield , have peculiar error. code below compares impactlabel1 text variable impactlabel1 set. if there change in textfield not equal variable setheadingsbutton shows. works if there single word no spaces in texfield. if there 2 words thinks not equal when same. nslog displays both values same also.

-(void) textfielddidendediting:(uitextfield *)textview { nslog (@"%@", impactlabel1.text); nslog (@"%@", impactlabel1);      if (impactlabel1.text != impactlabel1) {     [setheadingsbutton setalpha:1]; }     nslog (@"%@", impactlabel1.text);     nslog (@"%@", impactlabel1); } 

you should use isequaltostring method instead of "!=" operator. operator compares pointers, not actual string values.

-(void) textfielddidendediting:(uitextfield *)textview { nslog (@"%@", impactlabel1.text); nslog (@"%@", impactlabel1);      if (![impactlabel1.text isequaltostring: impactlabel1]) {     [setheadingsbutton setalpha:1]; }     nslog (@"%@", impactlabel1.text);     nslog (@"%@", impactlabel1); } 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -