Avoiding retain cycle when using a two-way NSXPCConnection

My current implementation has the following structure:
  1. In my implementation of NSXPCListenerDelegate I create the Remote object via the remoteObjectProxy* family of API.

  2. I then create the Local object that has a strong reference to Remote

  3. Local is then set as exportedObject of the Connection object

Did I just create a reference cycle (Connection -> Local -> Remote -> Connection)?

The strategy I'm considering right now is to drop the reference to Remote and request it from Connection (unless invalidated) whenever it's needed. But that's a bit inconvenient as I need to somehow refer to Connection from Local.

The latter can be solved via a weak (or unowned?) reference from Local to Connection. But then it's important to know whether Connection will retain Local (its exportedObject) until deallocated or until invalidated.

Please advise what'd be the best way to proceed.
Post not yet marked as solved Up vote post of Kentzo Down vote post of Kentzo
626 views