Re: File's owner and delegate
Re: File's owner and delegate
- Subject: Re: File's owner and delegate
- From: Joakim Danielson <email@hidden>
- Date: Wed, 12 May 2004 17:15:58 +0200
On 12 maj 2004, at 15.20, Allan Odgaard wrote:
>
On 12. May 2004, at 14:21, Joakim Danielson wrote:
>
>
> I'm trying to bind the content of a NSObjectController to an ivar in
>
> my controll class but I end upp with the error message
>
> "[<NSWindowController 0x348b20> valueForUndefinedKey:]: this class is
>
> not key value coding-compliant for the key delegate."
>
>
Is this when loading MainMenu.nib or one of the other nibs (containing
>
a window)?
One of the other nibs.
>
>
> _wcTransactions = [[NSWindowController alloc]
>
> initWithWindowNibName:@"Transaction"];
>
>
This will load the Nib with File's Owner being the window controller.
>
You probably want to use the initWithWindowNibName:owner: version, and
>
give the application delegate as owner.
>
That plus setting my control class (JDTransactionControll) as File's
owner in IB did the trick. One follow up question: Now I have one
instance of my control class in the nib file and one in the method
call, or will one of them be replaced by the other?
- (IBAction)showAdminTransactions:(id)sender {
if (_wcTransactions == nil) {
JDTransactionControll *ctrl = [[[JDTransactionControll alloc] init]
autorelease];
_wcTransactions = [[NSWindowController alloc]
initWithWindowNibName:@"Transaction" owner:ctrl];
}
[_wcTransactions showWindow:self];
}
>
> In IB I have an instance of my controll class and connected it as a
>
> delegate to File's owner (NSApplication) and for the
>
> NSObjectController binding objectContent I have written
>
> delegate.transaction and set Bind To: to File's owner.
>
>
Is this in the same Nib? Cause then you are making the (AFAIK
>
non-documented) assumption that connections are created *before*
>
bindings.
>
>
I just did a test, and this currently is practice, so that shouldn't
>
be your problem, but I would file an enhancement request to get this
>
behavior documented, if you plan on making use of it (if I did not
>
overlook something in the documentation).
>
It's not connected anymore since it's now the File's owner. See above.
>
> So why is NSWindowController the receiver of "delegate" and not my
>
> controll class?
>
>
I'd say because File's Owner is the window controller. I assume that
>
this is not in the MainMenu.nib, and thus the problem is with your
>
window controller initialization where you do not specify an owner.
Thank you for your reply. I'm learning step by step how to think and
how to work when programming with Cocoa's AppKit. Some times it's
frustrating, sometimes it's great fun.
Joakim
_______________________________________________
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.