ios - Update UILabel from NSUserDefaults -


i trying save/load data game (in case, # of tips player has available them). if playing game first time, 10 tips start with, otherwise, load number of tips had before last quit game. issue when starting game first time, setting number of tips 10 uilabel displaying 0.

these here save , load methods:

- (void)savesettings {     nsuserdefaults *settings = [nsuserdefaults standarduserdefaults];     [settings setinteger:self.tipcount forkey:@"tipcount"]; }  - (void)loadsettings {     nsuserdefaults *settings = [nsuserdefaults standarduserdefaults];     if (![settings boolforkey:@"userdefaultsset"])     {         [settings setbool:1 forkey:@"userdefaultsset"];         [settings setinteger:10 forkey:@"tipcount"];         self.tipcount = 10;     } else {         self.tipcount = [settings integerforkey:@"tipcount"];     }     } 

and here how updating label:

- (void)updatelabel {     quiz* sharedquiz = [quiz sharedinstance];      self.statuslabel.text = [nsstring stringwithformat:@"tips remaining: %d", [sharedquiz tipcount]]; } 

any can point me in right direction appreciated. in advance!

here add few things question precautions, might so, have been taken care still trying see below.

check whether calling loadsetting method before calling other method (savesettings method , updatelabel method) want display information.look have not set value tips count besides single method(loadsetting) if method not caling means getting 0 number on uilabel.so should take care of single thing whether have called loadsetting method before showing tips count user on uilabbel.since after looking code seems u did in correct way should have done.

you can check out setting break point @ required place , check out main reason behind it.

i hope may helps , give idea can form above


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -