iphone - Condition always fails though the comparative values seems correct in iOS -


when check value of number in nslog shows '0'

    nsmutabledictionary *data = [[nsmutabledictionary alloc] initwithcontentsoffile: path];     nsnumber *number=[data objectforkey:@"serial"];     nslog(@"%@",number);     if(number ==0 )     {          imgbutton.hidden=yes;     } 

but condition fails , changed code

     nsstring *number=[data objectforkey:@"serial"]      nslog(@"%@",number);      if(number == @"0" )      {            imgbutton.hidden=yes;      } 

but here condition fail ,what issue this?

in first code checking nsnumber, object, against int. correct check is:

if([number intvalue] == 0) {     imgbutton.hidden = yes; } 

in second code checking 2 nsstring, have use "isequaltostring" method , not "==". correct code is:

if([number isequaltostring:@"0"]) {     imgbutton.hidden = yes; } 

Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -