Grief with NSDocument windowControllerDidLoadNib
Grief with NSDocument windowControllerDidLoadNib
- Subject: Grief with NSDocument windowControllerDidLoadNib
- From: Ken Tabb <email@hidden>
- Date: Wed, 27 Mar 2002 16:49:50 +0000
Hi,
I have an app with an NSDocument subclass and an NSWindowController
subclass, and I want to know the 'correct' way to prepare the window
after loading the nib file and prior to display. Basically the window
currently only contains an NSImageView, although once I get around this
problem there will be more (hence the need to subclass
NSWindowController). What I want to happen is:
[1] User selects 'Open'. (This works fine).
[2] NSDocument subclass loads image file and makes an NSImage from it.
(This works fine).
[3] NSDocument subclass adds (custom) window controller. (This works
fine).
[4] NSWindowController loads window's nib file and hooks everything up
as regards outlets / actions. (This works fine).
[5] Once the window controller has loaded the nib file OK, the
NSDocument subclass gives the NSImage to the window controller, to put
in its NSImageView. Currently this is a hack as I can't find an elegant
way of accomplishing this.
The problem I have in [5] is that there is a time delay between stages
[2] and [5], so when the document is ready to pass the NSImage over to
the window controller, the window controller hasn't yet loaded the nib
file or hooked anything (including the NSImageView) up. It seems the
document's windowControllerDidLoadNib is the correct place to put the
'delayed' handshaking code, but my document's windowControllerDidLoadNib
isn't getting called. And it's just not fair.
My NSDocument subclass' windowControllerDidLoadNib currently looks like
this:
- (void)windowControllerDidLoadNib:(NSWindowController *) aController
{
[super windowControllerDidLoadNib:aController];
// Add any code here that need to be executed once the
windowController has loaded the document's window.
printf("NSDocument windowControllerDidLoadNib called\n");
}
... But there is no such printout in the Project Builder 'Run' pane. It
doesn't matter whether I comment out the 'super' call, or remove the
whole method, either way the window controller loads the nib fine, it's
just this method isn't getting called. So I'm guessing that either:
[1] When you subclass NSWindowController, there is suddenly a different
way of doing this (which isn't obvious from the docs)
[2] I need to specifically invoke windowControllerDidLoadNib in my code
elsewhere (in which case, which method do I invoke it from?)
Thanks in advance for any help you can give,
Ken
- - - - - - - - - -
Ken Tabb
Mac & UNIX Technical bloke (C, C++, Obj-C, Java) - Health & Human
Sciences
Machine Vision & Neural Network researcher - Computer Science Dept
University of Hertfordshire, UK
http://www.health.herts.ac.uk/ken/
Certified non-Microsoft Solution Provider
_______________________________________________
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.