title: NSUserDefaults: detecting nil
body: <p>I have some code in my classes to read from NSUserDefaults</p>
  
  <pre><code>NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
  score = [defs integerForKey:@"score"];
  </code></pre>
  
  <p>this causes a crash.</p>
  
  <p>Im guessing it is because the score value is nil or doesnt exist.</p>
  
  <p>How can I check if it is nil?</p>
  
  <p>EDIT.</p>
  
  <p>The following code causes a crash when storing to NSUserDefaults.</p>
  
  <pre><code>NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
      [defs setInteger:0 forKey:@"score"];
      [defs setInteger:3 forKey:@"lives"];
      [defs release];
  </code></pre>
  
  <p>Im not sure what the issue is</p>
  
  <p>On some crashes there isnt even a crash report in the console.</p>
  
  <p>Thanks</p>