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

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

Android Gson.fromJson error -