iphone - problem with a string and parse XML -
i have logical condition not work. compare 2 characters, 1 taken xml , other insert myself.
to let know attaching below code
nsstring *telefono = [nsstring stringwithformat:@"%@", [[arraycolonnine objectatindex:indexpath.row]objectforkey:@"telefono"]]; nsstring *trimmedtelefono = [telefono stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; senzatelefono = [[nsstring alloc] initwithstring:[trimmedtelefono stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]]; if (telefono == @"no") if (trimmedtelefono == @"no") if (senzatelefono == @"no")
for each of 3 strings if log print no. in none of 3 cases if works. how can fix make work?
solution
the process this:
nsstring *telefono = [nsstring stringwithformat:@"%@", [[arraycolonnine objectatindex:indexpath.row]objectforkey:@"telefono"]]; nsstring *trimmedtelefono = [telefono stringbytrimmingcharactersinset:[nscharacterset whitespaceandnewlinecharacterset]]; if ([trimmedtelefono isequaltostring:@"no"]) { //do something... }
you should use isequaltostring:
if ([telefono isequaltostring:@"no"])
if (telefono == @"no")
compares objects being same, not contents being same.
Comments
Post a Comment