Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Style.

They will both be compiled to 0.

From what I can tell the stylistic difference is that NULL is used to indicate a null pointer to a primitive type, and nil is used to indicate a null pointer to an Object.

-Lee
 

iSee

macrumors 68040
Oct 25, 2004
3,539
272
Assuming we're talking about Objetive-C:
nil (all lower-case) is a null pointer to an Objective-C object.
Nil (capitalized) is a null pointer to an Objective-C class.
NULL (all caps) is a null pointer to anything else.

So, conceptually, they mean the same thing but for different categories of things. They all have the same representation, too; they all happen to have the numeric value of 0.

I don't know whether or not NIL (all upper-case) has special meaning in Objective-C.
 

Darkroom

Guest
Original poster
Dec 15, 2006
2,445
0
Montréal, Canada
Darkroom, I believe on your avatar, the letter immediately following NS should be capitalized.

but then it would be an ex-object... and NSSexObject doesn't play with the term/concept as much... anyway...:rolleyes:

Assuming we're talking about Objetive-C:
nil (all lower-case) is a null pointer to an Objective-C object.
Nil (capitalized) is a null pointer to an Objective-C class.
NULL (all caps) is a null pointer to anything else.

So, conceptually, they mean the same thing but for different categories of things. They all have the same representation, too; they all happen to have the numeric value of 0.

I don't know whether or not NIL (all upper-case) has special meaning in Objective-C.

so to get this straight...??

Code:
[NSApp beginSheet:sheet
   modalForWindow:mainWindow
      modalDelegate:nil                 [COLOR="SeaGreen"]//pointing to an [I]object[/I] (modelDelegate?) and making it zero?[/COLOR]
      didEndSelector:NULL             [COLOR="SeaGreen"]//pointing to a [I]non object/class[/I] and making it zero?[/COLOR]
           contextInfo:NULL];           [COLOR="SeaGreen"]//pointing to a [I]non object/class[/I] and making it zero?[/COLOR]
 

Littleodie914

macrumors 68000
Jun 9, 2004
1,813
8
Rochester, NY
Yea, the different types can get confusing at times. In all my experience, I've only used the "nil" and "NULL" keywords, referring to an objective-c object pointer, and a primitive type pointer, respectively. I've never needed anything else, but maybe I just haven't gotten deep enough. :D
 

certsoft

macrumors member
Sep 29, 2007
78
8
John Day, OR
NIL is a reserved word in Pascal, I don't know what it would be doing in C (although I've never used objective C). Like NULL, it's value is usually zero.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.