Re: message to nil? (very basic question)
Re: message to nil? (very basic question)
- Subject: Re: message to nil? (very basic question)
- From: David Remahl <email@hidden>
- Date: Sat, 19 Jan 2002 23:35:49 +0100
>
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?
>
>
Example: Do I have to check for nil, if I release an object?:
>
>
if (myObject != nil) { // is this necessary?
>
[myObject release]
>
}
>
>
Mani
Sending a message no nil is fine and can be done without ill-effects in
objective-C. Can't be done in Java. However, I notice people doing the check
for nil before releasing...Why? Is there a risk that this behaviour will be
changed in future revisions of the runtime?
/ david