title: Convert NSNumber to int in Objective-C
body: <p>I use <code>[NSNumber numberWithInt:42]</code> or <code>@(42)</code> to convert an int to NSNumber before adding it to an NSDictionary:</p>
  
  <pre><code>int intValue = 42;
  NSNumber *numberValue = [NSNumber numberWithInt:intValue];
  NSDictionary *dict = @{ @"integer" : numberValue };
  </code></pre>
  
  <p>When I retrieve the value from the NSDictionary, how can I transform it from NSNumber back to int?</p>
  
  <pre><code>NSNumber *number = dict[@"integer"];
  int *intNumber = // ...?
  </code></pre>
  
  <p>It throws an exception saying casting is required when I do it this way:</p>
  
  <pre><code>int number = (int)dict[@"integer"];
  </code></pre>