Re: Obj-C difference between NULL and nil
Re: Obj-C difference between NULL and nil
- Subject: Re: Obj-C difference between NULL and nil
- From: Brian Hill <email@hidden>
- Date: Sat, 26 May 2001 11:46:42 -0500
On Saturday, May 26, 2001, at 11:33 AM, Chris Lemler wrote:
I have been reading thru the code for various Obj-C programs, and I
have seen some people consistently use NULL, and others use nil:
NSMutableArray *myArray;
myArray = NULL;
or
myArray = nil;
Are there any real advantages to using one over the other? Does it make
any difference when releasing an object that was never allocated:
myArray = NULL;
[myArray release];
versus
myArray = nil;
[myArray release];
They're both just typecast zero's. Functionally, there's no difference.
ie.,
#define NULL ((void*)0)
#define nil ((id)0)
Conceptually, there is a difference, but only to yourself and other
humans that read the code, the compiler doesn't care.
Brian
email@hidden
http://personalpages.tds.net/~brian_hill
"Why? I came into this game for adventure - go anywhere, travel
light, get in, get out, wherever there's trouble, a man alone.
Now they've got the whole country sectioned off and you can't
move without a form. I'm the last of a breed."
-- Archibald "Harry" Tuttle, Rogue HVAC Repairman