• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Obj-C difference between NULL and nil
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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



  • Follow-Ups:
    • Re: Obj-C difference between NULL and nil
      • From: Wilfredo Sanchez <email@hidden>
References: 
 >Obj-C difference between NULL and nil (From: Chris Lemler <email@hidden>)

  • Prev by Date: Fwd: Obj-C difference between NULL and nil
  • Next by Date: Re: Why Objective-C over Java?
  • Previous by thread: Obj-C difference between NULL and nil
  • Next by thread: Re: Obj-C difference between NULL and nil
  • Index(es):
    • Date
    • Thread