• 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: Add same object/key to NSMapTable
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Add same object/key to NSMapTable


  • Subject: Re: Add same object/key to NSMapTable
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 17 Jun 2009 18:58:59 -0700

On Wed, Jun 17, 2009 at 6:48 PM, Nathan Vander
Wilt<email@hidden> wrote:
> Isn't it acceptable practice to let a container object I hold to maintain
> its objects on my behalf?

Not explicitly, no.  Take -[NSWindowController delegate], for example.
 Because delegates are a weak reference, the contract is explicit that
your delegate must always be valid from the time you set it to be so
to the time the NSWindowController instance is deallocated *or* you
call -setDelegate: with a different object.  It's this explicit
contract which lets NSWindowController not have to wrap all accesses
to its delegate with -retain/-release calls.

In the specific context you illustrate, you're violating the
rule-of-thumb that once you release an object for good you don't
message it again.

--Kyle Sluder
_______________________________________________

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: 
 >Add same object/key to NSMapTable (From: Nathan Vander Wilt <email@hidden>)
 >Re: Add same object/key to NSMapTable (From: Kyle Sluder <email@hidden>)
 >Re: Add same object/key to NSMapTable (From: Nathan Vander Wilt <email@hidden>)

  • Prev by Date: Re: Add same object/key to NSMapTable
  • Next by Date: Re: Add same object/key to NSMapTable
  • Previous by thread: Re: Add same object/key to NSMapTable
  • Next by thread: Problem with capturing active state of the application
  • Index(es):
    • Date
    • Thread