Friday, June 3, 2011

NSNull, nil, null differences

Found a great answer on stack overflow.  Here's the gist of it:

nil is like (NSObject *)0
NULL is like (void*)0
Both are pointers with an integer value of zero.

NSNull is a helper object to add nil to NSArray or container classes requiring an object.  Similar to how NSNumber is needed to add an int.  [NSNull null] can be used instead of nil.  You can't compare NSNull to nil, but you can check if something is a NSNull.

No comments:

Post a Comment