• 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: Proper Way to "Unload" a Loaded Nib w/Bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Proper Way to "Unload" a Loaded Nib w/Bindings


  • Subject: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
  • From: "R. Matthew Emerson" <email@hidden>
  • Date: Tue, 27 Mar 2007 17:42:56 -0400


On Mar 27, 2007, at 4:29 PM, Guy English wrote:

There is insanity involved when you bind to the File's Owner. And by insanity I mean some nasty retain cycles can get created. See the thing is when you instantiate the nib you get a retain on it and when objects inside the nib bind to you they retain you. You don't know (normally) what has been bound to you so digging your self out of the hole is a pain.

The easiest solution is put a controller class in the nib and bind to that. Have an outlet from your File's Owner to this controller class instance. If you look at NSWindowController you'll see there's mechanisms in there to handle the autounbinding correctly. Ultimately it'd be great to get an NSViewController to do the same in the (increasingly common) circumstance.

I have been binding via File's Owner frequently. I have a document- based application with multiple windows per document. Each window has its own nib, and the File's Owner in each nib is an NSWindowController subclass. Typically, NSController instances in the nib bind to the document's managed object context and to model objects therein via the File's Owner (i.e., the window controller).


A typical key path would be something like "document.thing.widgets".

Should I not be doing this?  If not, how should I have known better?

(I'll be glad when we have garbage collection and can quit worrying about retain cycles.)



_______________________________________________

Cocoa-dev mailing list (email@hidden)

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: Proper Way to "Unload" a Loaded Nib w/Bindings
      • From: Guy English <email@hidden>
References: 
 >Proper Way to "Unload" a Loaded Nib w/Bindings (From: Keary Suska <email@hidden>)
 >Re: Proper Way to "Unload" a Loaded Nib w/Bindings (From: "Shawn Erickson" <email@hidden>)
 >Re: Proper Way to "Unload" a Loaded Nib w/Bindings (From: Guy English <email@hidden>)

  • Prev by Date: RE: where in the world is Kyle Hammond?
  • Next by Date: Re: making a custom view not grab the keyboard
  • Previous by thread: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
  • Next by thread: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
  • Index(es):
    • Date
    • Thread