• 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: Distributed Objects, delegates, and retain cycles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Distributed Objects, delegates, and retain cycles


  • Subject: Re: Distributed Objects, delegates, and retain cycles
  • From: Grigory Entin <email@hidden>
  • Date: Mon, 02 Oct 2006 04:00:20 +0400

Hello Derrick,

On Mon Oct 02 2006 at 01:42, Derrick Bass <email@hidden> wrote:

> I'm using Distributed Objects to perform a long operation in a
> separate process. The vended object communicates the operation's
> progress by calling a method in its delegate. The problem is that if
> the object doesn't retain the delegate then the proxy to it goes
> away, so its pointer becomes stale. On the other hand, if it does
> retain the delegate, the retain gets propagated back to the client;
> but the delegate happens to be the object that's retaining the
> vended object, so I get a retain cycle.
>
> Is there a good solution to this problem?

I'm not sure about other solutions, but when I faced the same problem,
I ended up with retaining the delegate (proxy) and creating the retain
cycle. I decided to follow one simple rule of thumb not to be affected
by the cycle: make the object that *sets* the delegate responsible for
resetting it to nil when appropriate (and therefore breaking the
retain cycle). It worked for me, and moreover, helped to keep the
model "clean".

Regards,
Grigory
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Distributed Objects, delegates, and retain cycles (From: Derrick Bass <email@hidden>)

  • Prev by Date: PDFDocument and PDFPage
  • Next by Date: Reading custom rtf attributes
  • Previous by thread: Distributed Objects, delegates, and retain cycles
  • Next by thread: Cocoaheads Lake Forest (CA) meeting THURSDAY 10/5
  • Index(es):
    • Date
    • Thread