Re: Multiple Types of Documents in a Document Based App
Re: Multiple Types of Documents in a Document Based App
- Subject: Re: Multiple Types of Documents in a Document Based App
- From: Jonathan Jackel <email@hidden>
- Date: Sun, 23 Jan 2005 21:03:16 -0500
I think I've got it started now. Subclassing NSDocumentController doesn't seem to be necessary. (I believe Anguish, Buck & Yachtman counsels against subclassing anyway.)
I did two things wrong. First, I forgot to hook up the "window" outlet of my "collection" doc subclass to the window in that doc's nib. Second, the order of the documents in the Document Types table in the Target/Properties view is important. The first document in that list is what the shared doc controller creates when the app starts up and when the "New" menu item is invoked. I had them reversed, and with no window outlet for the collection doc's nib, I got a whole lot of nothing.
Once I hooked up the nib connections properly and put the Document Types are in the right order (standard doc first, then collection doc), I was able to set up an action in my app's main controller
- (id)sender
{
id aDoc = [[NSDocumentController sharedDocumentController] openUntitledDocumentOfType:@"MyApp collection" display:YES];
}
This calls makeUntitledDocumentOfType: (according to the docs) and seems to set things up properly. My "New Collection" menu item triggers this action, while "New" still triggers the creation of a new standard document.
Jonathan
On Jan 23, 2005, at 3:19 PM, mmalcolm crawford wrote:
On Jan 23, 2005, at 12:00 PM, Jonathan Jackel wrote:
My plan was to create a new NSDocument subclass with its own UI to manage a list of docs and handle the collection management duties, but I can't even get the app to create a new empty document once I create a second document type. I must be missing something obvious.
Depending on your application architecture, you might subclass NSDocumentController:
<http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Classes/NSDocu entController.html>
see 'makeUntitledDocumentOfType:'
mmalc
_______________________________________________
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
_______________________________________________
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