title: iOS Casting to a BOOL
body: <p>Are these two lines of code different or the same (Edit: Do they do the same thing, typecast to a boolean?):</p>
  
  <pre><code>BOOL isRegistered = (BOOL)[[NSUserDefaults standardUserDefaults] valueForKey:@"DEVICE_REGISTERED"];
  
  BOOL isRegistered = [[[NSUserDefaults standardUserDefaults] objectForKey:@"Is Registered"] boolValue];
  </code></pre>
  
  <p>In iOS8.1 the first one is definitely failing. The cast to a bool is not working, the cast is always returning as false. The value is being stored (for the second example) like so:</p>
  
  <pre><code>[[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithFormat:@"%i", registerSuccess] 
                                            forKey:@"Is Registered"];
  </code></pre>
  
  <p>registerSuccess is a value returned from a web service (JSON). </p>