Check for NSNumber
<p>I want to check if an NSNumber exists for a property and exclude any cases where the variable is empty, undefined, nil, NULL etc.</p>

<p>Property is defined as follows:</p>

<p>@property (nonatomic, retain) NSNumber * id;</p>

<p>I have been using the following:</p>

<pre><code>if (item.id) {
//has a valid id such as 1,2,3,4
}
else {
//does not have a valid id.. could be 0, nil, NULL etc.
}
</code></pre>

<p>Am I doing this right?</p>

<p>Note, I know it is possible to check it using ([item.id intValue] != 0).  That is not my question.  My question is whether it is also possible to check as if (item.id) and if so why not?</p>

<p>For strings I usually check string lengths but for numbers, my understanding is, the length property is not available.</p>