• 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: Guy English <email@hidden>
  • Date: Tue, 27 Mar 2007 16:29:03 -0400

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.

Later,
Guy

On 27-Mar-07, at 2:51 PM, Shawn Erickson wrote:

On 3/27/07, James Bucanek <email@hidden> wrote:

If you know what your top-level objects are, send one release to each when you're done with the nib. (Remember that if you have release-on-close set for the window, the NSWindow will release itself.)

>Is there sample code for dynamically "unloading" a nib, especially without
>needing to know precisely what outlets are connected and what bindings
>exist. Basically what NSWindowController seems to do.


If you have an arbitrary or unknown set of top-level objects, do what
NSWindowController does: Use loadNibFile:externalNameTable:withZone:

Personally I would look at using NSNib and the functionality it provides to load and instantiate nibs, in particular instantiateNibWithOwner:topLevelObjects:. It is simpler to use. Note NSNib is a 10.3 and later API.

-Shawn
_______________________________________________

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:
40gmail.com


This email sent to email@hidden

_______________________________________________

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: "R. Matthew Emerson" <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>)

  • Prev by Date: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
  • Next by Date: Re: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
  • Previous by thread: Re: Proper Way to "Unload" a Loaded Nib w/Bindings [Solved, Maybe]
  • Next by thread: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
  • Index(es):
    • Date
    • Thread