• 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: Appropriate dealloc and finalize actions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Appropriate dealloc and finalize actions


  • Subject: Re: Appropriate dealloc and finalize actions
  • From: Chris Hanson <email@hidden>
  • Date: Tue, 13 Oct 2009 11:49:55 -0700

On Oct 12, 2009, at 8:25 AM, Jens Alfke wrote:

> On Oct 12, 2009, at 4:26 AM, Karolis Ramanauskas wrote:
>
>> As you can see each box has one or more little "inputs" and "outputs" in
>> fact these inputs and outputs are instances of one class (KROMPort). When I
>> drag a connection from output to an input, I set each "port's" connection
>> property to point to another "port". So Input points to Output and Output
>> points to Input. Only one-to-one relationships are allowed (one connection
>> per input/output).
>
> It's best not to do this kind of cleanup in dealloc/finalize. Instead, have an explicit method like -disconnect that's called to remove the object from the graph. That way you're in direct control of removing objects. And yes, when [foo disconnect] is called it will need to tell its connected object to clear the connection to itself.

It’s also good in cases like this not to represent ownership of objects via the graph, but by some outer container.

For example, if I were creating an application with documents that consisted of connected nodes, I’d have the document own (retain) the nodes and have the nodes just reference (assign) each other.

That would allow me to keep “stop referencing node A from node B” distinct from “remove node A from the document.”  The latter may imply the former, but the former generally doesn’t imply the latter.

  — Chris


_______________________________________________

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

  • Follow-Ups:
    • Re: Appropriate dealloc and finalize actions
      • From: Karolis Ramanauskas <email@hidden>
References: 
 >Re: Appropriate dealloc and finalize actions (From: Greg Guerin <email@hidden>)
 >Re: Appropriate dealloc and finalize actions (From: Karolis Ramanauskas <email@hidden>)
 >Re: Appropriate dealloc and finalize actions (From: Kai Brüning <email@hidden>)
 >Re: Appropriate dealloc and finalize actions (From: Karolis Ramanauskas <email@hidden>)
 >Re: Appropriate dealloc and finalize actions (From: Jens Alfke <email@hidden>)

  • Prev by Date: Re: arrayWithContentsOfFile
  • Next by Date: Re: arrayWithContentsOfFile
  • Previous by thread: Re: Appropriate dealloc and finalize actions
  • Next by thread: Re: Appropriate dealloc and finalize actions
  • Index(es):
    • Date
    • Thread