• 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: How far with accessors?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How far with accessors?


  • Subject: Re: How far with accessors?
  • From: Jeff Biggus <email@hidden>
  • Date: Wed, 26 May 2004 18:36:57 -0500

On May 26, 2004, at 6:27 PM, cricket wrote:

[self setTheString:nil] will release the object and nil out the instance variable in one swell foop. That's why it's a nice way to do it.

But as far as coding style goes, it seems much less clear what is happening,
and could cause troubles down the line.

[self setTheString:nil] implies that theString exists and that its *value* is being set to nil.
However, [theString release] is clearly releasing the *object*.

It also seems to requires assumptions made about the setter's internal code,
which the act of releasing an object should be oblivious to.
(One should be able to freely rework setter methods without thinking about how
someone might be using them to deallocate objects.)

Perhaps this is bordering on complete triviality, but it seems poor style
and creates more message passing than is necessary.

-jeff
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: How far with accessors?
      • From: Ondra Cada <email@hidden>
    • Re: How far with accessors?
      • From: Finlay Dobbie <email@hidden>
References: 
 >Fwd: How far with accessors? (From: Ondra Cada <email@hidden>)
 >Re: How far with accessors? (From: Jeff Biggus <email@hidden>)
 >Re: How far with accessors? (From: cricket <email@hidden>)

  • Prev by Date: Re: Changing the desktop picture
  • Next by Date: Re: NSTextView baseline for line of text
  • Previous by thread: Re: How far with accessors?
  • Next by thread: Re: How far with accessors?
  • Index(es):
    • Date
    • Thread