• 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: Cocoa and messages to nil, revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa and messages to nil, revisited


  • Subject: Re: Cocoa and messages to nil, revisited
  • From: "Paulo F. Andrade" <email@hidden>
  • Date: Thu, 9 Aug 2007 15:07:55 +0100

Having coded in Java a lot, I must say messaging to nil is very refreshing :).
When I started with ObjC/Cocoa (not so long ago) I did a few


if(obj != nil)
	[obj whatever];

Until I discovered messaging to nil is "safe" and a common practice.
I said "safe" because it is _safe_ as long as you stay in OO world.
If you start using methods that return a struct or a long long, you might get in trouble with the return value.


Paulo F. Andrade 52439@IST
mailto: email@hidden



On 2007/08/09, at 13:02, Raphael Sebbe wrote:

Well, nil receivers lead to nil return values, which themselves lead to nil
arguments. arguments can be tested with asserts, where relevant. Contrarily
to your approach, where every message to nil would be logged...


And I guess the main idea is not to write complicated code, but to write
simple code instead.


Raphael

On 8/9/07, Jeff Laing <email@hidden> wrote:

passing nil arguments may be completely valid, depending on
your methods.

Oh ye gods and little fish, did I say nil arguments were invalid?

Its nil *receivers* that are the problem I'm trying to catch.

Sorry about that but sometimes it seems like everyone deliberately tries
to
miss the point - I wonder some times how people manage to actually write
complicated code...


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
40mega.ist.utl.pt


This email sent to email@hidden

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >RE: Cocoa and messages to nil, revisited (From: Jeff Laing <email@hidden>)
 >Re: Cocoa and messages to nil, revisited (From: "Raphael Sebbe" <email@hidden>)

  • Prev by Date: Hiding MainMenu.nib contents for NSStatusBar based applicatiton
  • Next by Date: Cocoa and PICT
  • Previous by thread: Re: Cocoa and messages to nil, revisited
  • Next by thread: Is this the Mailing list?
  • Index(es):
    • Date
    • Thread