Re: message to nil? (very basic question)
Re: message to nil? (very basic question)
- Subject: Re: message to nil? (very basic question)
- From: Bill Bumgarner <email@hidden>
- Date: Sun, 20 Jan 2002 18:29:02 -0500
Actually, Ondra was right.
Messages to nil will *never* cause a problem.... Andrew's message-- and
Vince's followup-- refer to attempting to find meaning in whatever is
returned by a message to nil.
I.e.:
NSView *foo = nil;
NSRect bounds;
float x;
[foo bounds]; // will always work
bounds = [foo bounds]; // will always work but...
x = bounds.size.width; // ... will be undefined
x = [foo bounds].size.width; // messaging will work, rest will not
--
A bit of a nit, admittedly.
b.bum
On Sunday, January 20, 2002, at 05:55 PM, cocoa-dev-
email@hidden wrote:
Read the rest of Andrew's message a bit more carefully, he is correct.
If the nil object returns a float or a structure you might not get back 0.
0 in the case of floats or and empty stucture.
its okay for objects and ints.