title: How to add to a saved NSUserDefault?
body: <p>I am making a game in Xcode which in includes a scoring system in each level. Here I have some code that gets an NSString (passedValue1) by using a delegate.</p>
  
  <p>Then i add the code to receive the value in my viewDidLoad and display my value in a UILabel</p>
  
  <pre><code>-(void)viewDidLoad
      { 
  
  
          [super viewDidLoad];
          // Do any additional setup after loading the view, typically from a nib
  
          // Do any additional setup after loading the view, typically from a nib
          NSString *key=@"labelKey";
  
          if(passedValue1){
              NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
  
              NSObject * object = [prefs valueForKey:key];
              if(object != nil){
                  NSUserDefaults *defults = [NSUserDefaults standardUserDefaults];
                  [defults setValue:passedValue1 forKey:key];
                  [defults synchronize];
              }
              else{
                  NSUserDefaults *defults = [NSUserDefaults standardUserDefaults];
  
                  NSInteger readScore=[[[NSUserDefaults standardUserDefaults] valueForKey:key] integerValue];
                  NSInteger newValue=readScore+[passedValue1 integerValue];
                  [defults setValue:[NSString stringWithFormat:@"%d",newValue] forKey:key];
                  [defults synchronize];
  
              }
          }
          label.text = [[NSUserDefaults standardUserDefaults]objectForKey:key];
      }
  </code></pre>
  
  <p>Once I have displayed the value I then save it into a label using a NSUserDefault. However, once I have replayed my game and have another score value I would like to add the new passedValue1 value to the currently saved value...</p>
  
  <p><strong>For example:</strong>
  say I play my level and I get the score value of 10. The value is then saved and I replay my level. I would then like to take the saved value and add it to the value i just scored. So thats say the second value I have scored is 20. I would then like my code to add them together and give me a value of 30.
  can anyone help because the code I'm using does not correctly do the function that I want to do which is add the previous and the currently passed value.</p>
  
  <p>What is wrong with my code??</p>
  
  <p>Thanks in advance.</p>