• 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: 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.


  • Follow-Ups:
    • Re: message to nil? (very basic question)
      • From: Christophe Dore <email@hidden>
  • Prev by Date: A slight addendum to the Finder recognizing link/unlink problem
  • Next by Date: HTML Parser
  • Previous by thread: Re: message to nil? (very basic question)
  • Next by thread: Re: message to nil? (very basic question)
  • Index(es):
    • Date
    • Thread