Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 15, 2008, 09:24 AM   #1
Darkroom
Guest
 
Join Date: Dec 2006
Location: Montréal, Canada
The Difference Between NIL and NULL...

... is what exactly?
Darkroom is offline   0 Reply With Quote
Old Jul 15, 2008, 09:36 AM   #2
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: 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
lee1210 is offline   0 Reply With Quote
Old Jul 15, 2008, 09:37 AM   #3
TimJim
macrumors 6502a
 
Join Date: May 2007
NIL is no value/zero. We're winning 5-nil
NULL is the absence of data (when writing software)
TimJim is offline   0 Reply With Quote
Old Jul 15, 2008, 11:10 AM   #4
iSee
macrumors 68030
 
iSee's Avatar
 
Join Date: Oct 2004
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.
iSee is offline   0 Reply With Quote
Old Jul 15, 2008, 05:47 PM   #5
NSNick
macrumors regular
 
Join Date: Jun 2008
Location: Washington D.C.
Darkroom, I believe on your avatar, the letter immediately following NS should be capitalized.
NSNick is offline   0 Reply With Quote
Old Jul 15, 2008, 06:17 PM   #6
Darkroom
Thread Starter
Guest
 
Join Date: Dec 2006
Location: Montréal, Canada
Quote:
Originally Posted by NSNick View Post
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...

Quote:
Originally Posted by iSee View Post
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                 //pointing to an object (modelDelegate?) and making it zero?
      didEndSelector:NULL             //pointing to a non object/class and making it zero?
           contextInfo:NULL];           //pointing to a non object/class and making it zero?
Darkroom is offline   0 Reply With Quote
Old Jul 15, 2008, 06:27 PM   #7
Catfish_Man
macrumors 68030
 
Catfish_Man's Avatar
 
Join Date: Sep 2001
Location: Portland, OR
Send a message via AIM to Catfish_Man
That looks correct.
Catfish_Man is offline   0 Reply With Quote
Old Jul 15, 2008, 08:30 PM   #8
HiRez
macrumors 601
 
HiRez's Avatar
 
Join Date: Jan 2004
Location: Western US
Don't forget NSNull!
__________________
Go outside, the graphics are amazing!
HiRez is offline   0 Reply With Quote
Old Aug 30, 2008, 07:38 PM   #9
stimpy77
macrumors newbie
 
Join Date: Aug 2008
Quote:
Originally Posted by HiRez View Post
Don't forget NSNull!
Please share.

EDIT: Nevermind.

http://developer.apple.com/documenta...cles/Null.html

NSNull is a singleton object used to represent a null value where nil is prohibited, namely collections. I come from the Windows world, this kinda reminds me of System.DBNull in C# ...
stimpy77 is offline   0 Reply With Quote
Old Aug 30, 2008, 08:41 PM   #10
Littleodie914
macrumors 68000
 
Littleodie914's Avatar
 
Join Date: Jun 2004
Location: 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.
Littleodie914 is offline   0 Reply With Quote
Old Aug 31, 2008, 07:19 PM   #11
certsoft
macrumors member
 
Join Date: Sep 2007
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.
certsoft is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
The difference between China and the western world Giuly Picture Gallery 17 Mar 21, 2011 06:31 PM
What's the difference between Flat and Off Equalizer settings on Touch and iPhone. LoganT iPhone Tips, Help and Troubleshooting 3 Dec 13, 2009 09:55 PM
Whats the difference between "empty" and "securely empty" the trash? marold280 OS X 5 Dec 27, 2008 08:06 AM
What's the difference between DVD-RW and DVD+R/RW onlydroops Macintosh Computers 8 Sep 18, 2003 03:29 PM
Whats the difference between g3 and g4? applesurferrr Hardware Rumors 4 Jan 3, 2002 11:20 PM


All times are GMT -5. The time now is 03:04 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC