Re: Proper Way to "Unload" a Loaded Nib w/Bindings
Re: Proper Way to "Unload" a Loaded Nib w/Bindings
- Subject: Re: Proper Way to "Unload" a Loaded Nib w/Bindings
- From: Keary Suska <email@hidden>
- Date: Tue, 27 Mar 2007 13:21:50 -0600
- Thread-topic: Proper Way to "Unload" a Loaded Nib w/Bindings
on 3/27/07 12:51 PM, email@hidden purportedly said:
>> 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.
I am using the NSBundle method, modeled after the docs:
[[NSBundle mainBundle] loadNibFile:name externalNameTable:nameTable
withZone:nil]
The problem is that when I release the top level objects, my app crashes. My
research seems to show that this is because of an NSWindow's
initialFirstResponder outlet being set. The docs warn that all outlets
should be set to nil for all objects in the nib, but don't mention how this
may be done when the outlets aren't known by the nib owner. Manually
tracking outlets would be a huge pain, so I was hoping there was some way to
detect connected outlets in a nib and "disconnect" them. NSWindowController
seems to accomplish this
I am also not sure whether bindings will gracefully "let go", or if I need
to unbind as well to avoid crashes.
Best,
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
_______________________________________________
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