Re: Subclassing NSWindowController
Re: Subclassing NSWindowController
- Subject: Re: Subclassing NSWindowController
- From: Steve Martin <email@hidden>
- Date: Fri, 6 Dec 2002 10:26:56 +1100
Message: 1
Date: Thu, 5 Dec 2002 02:50:50 -0800
Subject: Re: Subclassing NSWindowController
From: Dietrich Epp <email@hidden>
To: Cocoa Developer List <email@hidden>
On Thursday, December 5, 2002, at 02:16 , Chaffinch wrote:
Hi,
I am writing a text editor as a way of learning Cocoa. I want to
customise
the window title to display the full path name. I have managed to
implement
this by subclassing NSWindowController and overriding the
windowTitleForDocumentDisplayName method. So far so good. I have also
overridden MyDocument's makeWindowControllers method to create the
window
controller and call addWindowController. So far so good.
Only now, opening or saving a document no longer works??
I have read through the Apple docs, and have made the NSTextView member
(previously owned by the document) a member of the subclassed
NSWindowController. And overridden windowDidLoad in an attempt to load
the
document.
Am I correct in thinking that I still need the loadDataRepresentation
and
dataRepresentaionOfType methods in the document class to load and save
the
document but that the actual displaying is now done by the windo
controller?
Let's go through the motions...
1) Document class. It should have the loading / saving /
window-creating code.
2) Subclass of NSWindowcontroller. Created like (in document class):
- (void)makeWindowControllers {
_myWindowController = [[[MYWindowController alloc] init]
autorelease];
[self addWindowController:_myWindowController];
}
Any problems here? Part II: connections
What do you mean by that loading & saving doesn't work? Specifics help,
such as 'Save' and 'Open' are disabled, or 'Save' doesn't write files.
If the last line is missing from above, 'save' should be disabled, and
opened documents should not show any data. How does your document read
the text? Through an IBOutlet or similar connection? This won't work
with window controllers, the connection will go to the window controller.
by default, I understand the Open and Save menu items will be
disabled unless they are connected to Action methods (which can be
done by ctl-dragging in IB). I think the normal way to handle this is
with a delegate for the NSApplication that contains these Action
methods and tells the document to save itself.
Steve
_______________________________________________
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.