title: check if NSNumber is empty
body: <p>How do I check if a NSNumber object is nil or empty?</p>
  
  <p>OK nil is easy:</p>
  
  <pre><code>NSNumber *myNumber;
  if (myNumber == nil)
      doSomething
  </code></pre>
  
  <p>But if the object has been created, but there is no value in it because an assignment failed, how can I check this? Use something like this?</p>
  
  <pre><code>if ([myNumber intValue]==0)
     doSomething
  </code></pre>
  
  <p>Is there a general method for testing objects on emptiness like for NSString available (see this <a href="http://www.wilshipley.com/blog/2005/10/pimp-my-code-interlude-free-code.html" rel="noreferrer">post</a>)?</p>
  
  <p><strong>Example 1</strong></p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  [dict setValue:@"" forKey:@"emptyValue"];
  NSNumber *emptyNumber = [dict objectForKey:@"emptyValue"];
  </code></pre>
  
  <p>Which value does <code>emptyNumber</code> contain? How can I check if <code>emptyNumber</code> is empty?</p>
  
  <p><strong>Example 2</strong></p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  [dict setValue:@"" forKey:@"emptyValue"];
  NSString *myString = [dict objectForKey:@"emptyValue"];
  if (myString == nil || [myString length] == 0)
      // got an empty value
      NSNumber *emptyNumber=nil;
  </code></pre>
  
  <p>What happens if I use this after <code>emptyNumber</code> was set to nil?</p>
  
  <pre><code>[emptyNumber intValue]
  </code></pre>
  
  <p>Do I get zero?</p>
  
  <p><strong>Example 3</strong></p>
  
  <pre><code>NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
  [dict setValue:@"" forKey:@"emptyValue"];
  NSNumber *myEmptyValue = [dict objectForKey:@"emptyValue"];
  if (myEmptyValue == nil)
      // NSLog is never called
      NSLog(@"It is empty!");
  </code></pre>
  
  <p>Like this way NSLog is never called. <code>myEmptyValue</code> is not <code>nil</code> and not <code>NSNull</code>. So it contains an arbitrary number?</p>