title: Compare NSNumber with NSInteger
body: <p>I spent some time today chasing down two bugs, and ended up fixing both of them using the same solution.</p>
  
  <p>Now that I have the solution, I was hoping to get some clarity behind it.</p>
  
  <p>I'm comparing an attribute from Core Data (Integer 16/NSNumber) with an Integer (ABPropertyID &amp; ABMultiValueIdentifier).</p>
  
  <p>The bug was in this comparison, and oddly enough, only showed itself after I had killed the app (from the background tray), reopened it, and run through the same process that included the comparison.  Anyways...</p>
  
  <p>This is what stopped working after a restart:</p>
  
  <p><code>if (myNumber.aProperty == [NSNUmber numberWithInt:anInteger]) { /* do stuff here */ }</code></p>
  
  <p>And these are the two solutions, which so far, are working perfectly:</p>
  
  <p><code>if ([myNumber.aProperty integerValue] == anInteger) {/* do stuff here */ }</code></p>
  
  <p><code>if ([myNumber.aProperty isEqualToNumber:[NSNumber numberWithInt:anInteger]]) { /* do stuff here */ }</code></p>
  
  <p>To me, they all look identical.  I'm always either converting the NSNumber to an integerValue, or converting the integer to an NSNumber.</p>
  
  <p>Any ideas?</p>