0

How do I make it that green.png color always stays saved in the game. When game ends, green goes back to the original color and it's not saved. So I have to click on green all the time before the game. I want it to be saved always when the user clicked it once, unless the user clicks a different color.

MAN = BOOLEAN

if ((dude.center.x < 100)  && (CGRectIntersectsRect(dude.frame, ground.frame)) &&(MAN==YES)) {
    dude.image=[UIImage imageNamed:@"green.png"];

 [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"save"];
 MAN= [[NSUserDefaults standardUserDefaults]boolForKey:@"save"];
 [[NSUserDefaults standardUserDefaults]synchronize];
    }

The BELOW code for saving BOOL isn't working at all.

    [[NSUserDefaults standardUserDefaults]setBool:YES forKey:@"save"];
    MAN= [[NSUserDefaults standardUserDefaults]boolForKey:@"save"];
    [[NSUserDefaults standardUserDefaults]synchronize];  //iOS 7

//Not using [[NSUserDefaults standardUserDefaults]synchronize]; for iOS 8

Is there a different way to save BOOL?

Jet
  • 555
  • 1
  • 7
  • 19
  • If you are using Core Data you can save it in there. Or you can make your own plist and change your own keys and value then overwrite the file again. – emotality Apr 29 '15 at 14:09
  • try wraping it in an NSNumber, Later you'll be able to retrieve that value as plain BOOL using ````-boolForKey:```` function in NSUserDefaults. [http://stackoverflow.com/questions/5587505/save-bool-in-nsuserdefaults](http://stackoverflow.com/questions/5587505/save-bool-in-nsuserdefaults) – Nirav Dangi Apr 29 '15 at 14:14
  • Please stop posting your questions over and over. This is now the 3rd time you have posted this same question. Instead of posting it over and over, please update the original question with more details as needed. – rmaddy Apr 29 '15 at 14:21

0 Answers0