Friday, 10 September 2010

Objective C - NSUserDefaults with NSInteger not working


i using nsuserdefaults set nsinteger
code:
  nsuserdefaults *savefile = [nsuserdefaults standarduserdefaults];     [savefile setinteger:2 forkey:@"savekey"];      working save game function. in view controller using following code load game   nsuserdefaults *savefile = [nsuserdefaults standarduserdefaults];     nsinteger saveint = [savefile integerforkey:@"integerkey"];      if (saveint == 2) {           l2raul1viewcontroller * raul1 = [[l2raul1viewcontroller alloc]initwithnibname:nil bundle:nil];         [self presentmodalviewcontroller:raul1 animated:yes];     } 
but reason isn't working. keep in mind being done in different view controllers, , needs done in many other view controllers.
 

look @ these 2 lines , spot difference:

code:
[savefile setinteger:2 forkey:@"savekey"];   ...  nsinteger saveint = [savefile integerforkey:@"integerkey"];
(hint: what's name of key holds integer?)
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment