Bindings across multiple Nibs
Bindings across multiple Nibs
- Subject: Bindings across multiple Nibs
- From: Peter Baumgartner <email@hidden>
- Date: Mon, 20 Mar 2006 15:23:20 +0100
Hi All,
I have a document based app with a Nib file for the document, which
contains the window and several blue cubes (frontend controllers for
the UI). The document window also contains an inspector with a popup
menu (transition type) and various other controls that need to be
exchanged depending on the selected menu item in the popup. Since the
application should be extensible via plugins, I would like to put the
controls for each transition in a separate Nib file.
The Nib file contains a view with the necessary controls. It is
loaded with:
[self removeAllControls];
BOOL loaded = [NSBundle loadNibNamed:nibName owner:_document];
NSView* view = [_document transitionControlsView];
if (loaded && view!=nil)
{
[self installControls:view];
[view release];
}
I remove any existing subviews from the container view and make the
view from the Nib the new subview of my container view.
I figured out how to make binding work across multiple Nib files,
using File's Owner, and making sure that each File's Owner is of the
same class (in my case the document subclass). Then I simply bind the
controls to the File's Owner with an appropriate keypath.
So far that works fine. A problem sometimes occurs when closing the
document window or quitting the app. Apparently all top level objects
in the Nib files are autoreleased and release order is not clearly
defined (can anybody confirm this?). If the controller (blue cube)
gets dealloced before a control that has a binding to this
controller, then a crash occurs when the control tries to unbind
(from the now missing controller) in its own dealloc method.
Why does this happen? Shouldn't the control retain the controller it
is bound to and thus force a proper dealloc order? What did I do
wrong? I hope that my explanation was sufficient.
Any help would be greatly appreciated.
Peter Baumgartner
IMAGINE GbR
Console exception message
---------------------------------------
2006-03-18 12:44:14.503 FotoMagico[609] An instance 0x16812c20 of
class TransitionOptionsController? is being deallocated while key
value observers are still registered with it. Break on
_NSKVODeallocateLog to start debugging.
Document NIB (file's owner is document subclass)
---------------------------------------------------------------------
FMTransitionOptionsController (blue cube in IB)
NSWindow
Content View
...
NSPopUpButton (transition type)
NSView (container view)
...
Plugin NIB (file's owner is document subclass)
---------------------------------------------------------------
NSView (content view)
Various controls (bound to file's owner with keypath
_transitionOptionsController.propertyName)
...
_______________________________________________
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