title: How to store an retrieve float from NSUserDefaults
body: <p>I'm having trouble storing and retrieving a float in NSUserDefauts. I store the value, but when I retrieve it, it returns 0.</p>
  
  <p>here's what I tried and didn't work:</p>
  
  <pre><code>[pref setFloat:3.0f forKey:@"key"];
  float value = [pref floatForKey:@"key"]; //value=0
  
  [pref setFloat:3 forKey:@"key"];
  float value = [pref floatForKey:@"key"];//value=0
  
  [pref setObject:[NSNumber numberWithFloat:3] forKey:@"key"];
  float value = [[pref objectForKey:@"key"]floatValue];//value=0
  
  [pref setObject:[NSNumber numberWithFloat:3.0f] forKey:@"key"];
  float value = [[pref objectForKey:@"key"]floatValue];//value=0
  </code></pre>
  
  <p>What am I doing wrong here? I've tried these 4 pieces of code but they all return zero when retrieving the float from NSUserDefaults.</p>
  
  <p>Any help is appreciated.
  Thanks!</p>