• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Multiple document models.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multiple document models.


  • Subject: Re: Multiple document models.
  • From: mmalcolm crawford <email@hidden>
  • Date: Fri, 23 Jan 2004 00:18:06 -0800

On Jan 22, 2004, at 10:44 PM, April Gendill wrote:

Ok... This is probably a silly question or maybe I am just doing this program backwards. I have an application I've tinkered with for months now when I have time here and there. I chose to split it into two different types of document. document 1 handles 4 files formats in array, dictionary, plain text and proprietary format. The second deals with a package file containing 6 different files and a master file. I have a document subclass for the one that handles the plain files and a different document subclass for the package. Each uses a different window controller of course. The first subclass was the default one (renamed) from the document based application template. The second I did from scratch. (empty file). Each has it's own nib. Finally I have a master application controller that does little more than handle newdocument, save and so on. and it passes notifications to get the window controllers to perform certain menu functions.

It sounds like you're working against the system. You should not need much more than different NSDocument subclasses for each data type. Each should handle save for its own type -- there should be no need for an application controller to deal with that, and it's not clear what notifications you need to send to the window controllers (or why you need different ones).

I want to have a preference that allows me to choose which document type the application starts with, OR to simply allow me to have the application open the last document I worked in.
How do I control the document type that will be opened at launch?

Briefly (one variant): Subclass NSDocumentController, instantiate it in MainMenu, set it to be NSApp's delegate, and implement:

- (BOOL)applicationOpenUntitledFile:(NSApplication *)sender
{
NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
NSString *docType = [ud stringForKey:DefaultDocType];
[self openUntitledDocumentOfType:docType display:YES];
return YES;
}


For a (slightly contrived) example of all this, see:
<http://homepage.mac.com/mmalc/CocoaExamples/MultiDocType.zip>

mmalc
_______________________________________________
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.

References: 
 >Multiple document models. (From: April Gendill <email@hidden>)

  • Prev by Date: Re: HEAD request using NSURLConnection
  • Next by Date: Re: NSTask Memory Problems
  • Previous by thread: Multiple document models.
  • Next by thread: truncating strings
  • Index(es):
    • Date
    • Thread