Re: Why is NULL used sometimes when documentation specifies nil?
Re: Why is NULL used sometimes when documentation specifies nil?
- Subject: Re: Why is NULL used sometimes when documentation specifies nil?
- From: Shawn Erickson <email@hidden>
- Date: Fri, 14 Jan 2005 20:50:40 -0800
On Jan 14, 2005, at 7:01 PM, Roarke Lynch wrote:
What is the difference between nil and NULL?
Why does the Foundation Reference for NSScanner specify nil to skip
search results, while the NSScanner example in "Strings"
documentation uses NULL to omit results?
[snip
So why is NULL used sometimes when documentation specifies nil?
Well nil is used to imply no object in Cocoa Objective-C and NULL for
traditional uses of NULL in C. In reality they are one in the same
value so they can be used interchangeably.
The code example, in a perfect world, should be using nil since
intoString is expecting an object.
-Shawn
Knowing that nil and NULL are essentially the same value, I was under
the impression that syntactically nil refers to "no object" while NULL
referrers to "a pointer to nothing", so in the the NSScanner method in
question since the argument is of type NSString** not NSString* NULL
is used because it is the second case.
Good catch, yeah it is wanting a pointer to an object (objects in
Objective-C are always by reference, aka pointer) so using NULL makes
perfect sense.
-Shawn
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden