• 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: message to nil? (very basic question)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: message to nil? (very basic question)


  • Subject: Re: message to nil? (very basic question)
  • From: Thomas Lachand-Robert <email@hidden>
  • Date: Sat, 19 Jan 2002 23:39:23 +0100

Le samedi 19 janvier 2002, ` 11:24 , Manfred Lippert a icrit :

Hi,

a very basic question from a Cocoa/Obj-C newbie:

Is it allowed to send a message to nil or will it crash or give some runtime
errors or such things?

It is allowed and just returns 0 or corresponding value of the type (NO for boolean, nil for pointers, etc.).

It is a major advantage over C++ IMHO.

Example: Do I have to check for nil, if I release an object?:

if (myObject != nil) { // is this necessary?
[myObject release]
}

Not necessary. But in your dealloc methods, it's a good idea to do
[myObject release]; myObject = nil;
since this ensures that you won't release it twice here.


Thomas Lachand-Robert
********************** email@hidden
<< Et le chemin est long du projet ` la chose. >> Molihre, Tartuffe.


References: 
 >message to nil? (very basic question) (From: Manfred Lippert <email@hidden>)

  • Prev by Date: Re: message to nil? (very basic question)
  • Next by Date: external editors
  • Previous by thread: Re: message to nil? (very basic question)
  • Next by thread: Re: message to nil? (very basic question)
  • Index(es):
    • Date
    • Thread