Controller binding dies in 2nd NIB
Controller binding dies in 2nd NIB
- Subject: Controller binding dies in 2nd NIB
- From: Fritz Anderson <email@hidden>
- Date: Wed, 28 Jan 2004 18:05:05 -0600
I have a window (call it the Problem Window), controlled with an
NSObjectController subclass, that works well when it, the controller,
and the model are loaded in the main NIB of an application. I now want
to "demote" this window to be opened secondary to another MVC complex
-- the main complex shows a list of objects each of which could be
displayed by a Problem Window.
What makes it a Problem is that the control bindings seem to disappear
after loading time. I've reduced ProblemModel to:
class ProblemModel : NSObject {
NSString * path;
}
- (void) setPath: (NSString *) aPath;
- (void) setPath: (NSString *) aPath
{
if (aPath != path) {
[path release];
path = [aPath retain];
}
}
- (id) init { path = @"foo"; return self; }
ProblemController is:
class ProblemController: NSObjectController {
IBOutlet FADropFileView * dropFile;
}
- (void) dropFileAction: (id) sender;
... where an FADropFileView is a target-and-action view that accepts
file drops, displays dropped icons, and returns a path when sent the
'path' message.
- (void) dropFileAction: (id) sender
{
[[self content] setValue: [dropFile path] forKey: @"path"];
}
Neither -dropFileAction: nor -setPath: are so trivial in practice, but
in the course of debugging, I've reduced them to the minimum shown.
The NIB file includes a ProblemModel; a window with an FADropFileView
bound to dropFile; and a controller that binds the value of an
NSTextField in the window to the ProblemModel's path. The text field is
not editable, and "Conditionally sets editable" is off.
I've verified that a ProblemModel gets -init when the NIB loads, and I
note the address. No other ProblemModel gets inited. The NSTextField
shows 'foo' as its contents, so the binding is there, at least at the
start.
I've verified that dropFileAction: and setPath: get called, and with
the expected values. In setPath:, self is the same ProblemModel as was
inited. The instance variable 'path' does get changed.
The contents of the NSTextField do not change, then or ever after.
Which means the binding has somehow broken, or I've missed a secret
ritual (or fundamental concept) somewhere.
Further experiments show: The simple arrangement I've shown works fine
when run from the main NIB. It also works fine when run from a NIB
loaded by a simple control action. I will continue to try to approach
the complexity of my problem case. (The parent, NIB-launching
controller is itself an NSController, for instance.)
Can someone tell me what my block on this might be?
-- F
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.