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
Post a Comment