In this case, you should use the first one; or rather, a slight variation:
if (dicValue) {
// blablabla...
}
NSNull
is for use when you need a valid object, for example for use as a dictionary key, array entry, or similar.
nil
is equal to (id)NULL
; it is generally taken to mean "No value".
[NSNull null]
, on the other hand, is an object holding an empty value; taken to mean "A value of None".
Very few methods return an NSNull
value, and it is generally only encountered if you introduce it yourself.
It exists mostly because nil
cannot be inserted into arrays; and works as an empty marker for arrays that require it.
On a related note; the "!= nil
" part of your expression is redundant; any valid pointer to an object evaluates to true in a boolean expression, and nil evaluates to false.