Re: Bindings - necessary to manually inform of updates?
Re: Bindings - necessary to manually inform of updates?
- Subject: Re: Bindings - necessary to manually inform of updates?
- From: Ken Tozier <email@hidden>
- Date: Sun, 10 Apr 2005 06:13:48 -0400
Thanks Jonathon (and off list Frédéric) It sounds like the two instance
"Controller" thing is the problem. I'll try your suggestions later
(after some sleep.)
Thanks again,
Ken
On Apr 10, 2005, at 5:59 AM, Jonathon Mah wrote:
Hi Ken,
On 10 Apr 2005, at 19:07, Ken Tozier wrote:
And the implementation is this:
@implementation AppController
- (id) init
{
self = [super init];
if (self)
{
NSWindowController *window = [[NSWindowController alloc]
initWithWindowNibName: @"test_window"];
Controller *controller = [[Controller alloc] init];
<snip>
The secondary nib contains an instantiated "Controller" object in the
instances pane.
The "content" outlet of the NSObjectController is connected to the
Controller object.
The text field in the secondary window is bound to the "fileName"
field of the NSObjectController like so:
Bind to: NSObjectController
Controller Key: selection
Model Key Path: fileName
It's a non editable field so all of the value transformer fields are
unchecked. (checking various ones didn't do anything anyway)
And that's basically it. When I launch the application the secondary
window appears but the text field is initially blank and remains
blank.
Well you have instantiated a Controller in your nib file, and hooked
your NSObjectController to it. In your AppController's -init method,
you're making a _separate_ Controller object and changing the fileName
of it (so it's not affecting the controller in your nib at all). One
way to fix this is to add an IBOutlet to controller in your
AppController class and drag AppController.h into the nib window to
let Interface Builder know about it (not the window you made, but the
one that lists the NSObjectController, your window, etc.). Then click
"File's Owner" and set its Custom Class to AppController, and connect
the controller outlet to the instantiated Controller. In your code,
change:
NSWindowController *window = [[NSWindowController alloc]
initWithWindowNibName: @"test_window"];
Controller *controller = [[Controller alloc] init];
to:
NSWindowController *window = [[NSWindowController alloc]
initWithWindowNibName:@"test_window" owner:self];
(The 'controller' variable is now an instance variable, and IB has set
it up for you.)
Hopefully that description wasn't too messy! :)
P.S. On a related note, are there any bindings debugging utilities
out there?
Nope, that's one of the issues at the moment.
Jonathon Mah
email@hidden
_______________________________________________
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