Re: Add same object/key to NSMapTable
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