• 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: NSDocuments without window associations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSDocuments without window associations


  • Subject: Re: NSDocuments without window associations
  • From: James DiPalma <email@hidden>
  • Date: Mon, 4 Nov 2002 19:10:05 -0800

If what you want is a model class, consider implementing a model class and then having your document subclass use your model to handle file i/o. I think NSDocument is the only class with a proper name and a proper set of responsibilities within Apple's document architecture. I don't recommend subclassing it to fundamentally change what it does.

That said, Apple provides little documentation that hints at using a separate model class, so they basically recommend using NSDocument as a model (would it be too confusing to start newbies with more classes in their PB template but give them a better design?). Also, some books and example code will use NSDocument as a data controller (as file's owner, some code connects NSDocument to view elements); this design makes your NSDocument subclass a document (responsible for holding together your model data, windows, and interacting with your document manager, NSDocumentController), your model, and your controller. It is sometimes simpler to explain all code that needs to be written in one file, but its not a good design.

How to implement a model class? A simple start would be subclassing NSDocument with a class that:
- has an instance variable for a model object
- alloc/inits a model during its init method
- forwards all file i/o calls to this model instance


-jim

On Wednesday, October 30, 2002, at 10:37 AM, chris corbell wrote:

Is it reasonable to try to use NSDocument in a way that will
disable or bypass its connection to an NSWindowController?

I would like to use the NSDocumentController/NSDocument
architecture, but I do not want my document class to be aware of
windows. I'm working with an XML format and I simply want my
document class to manage a tree representation of the document
and serve that to a more central controller class which interacts
with the application's model and GUI objects.

Has anyone tried to use NSDocument in this way, as a model
object that handles file i/o but does not directly deal with
windows?

I can experiment but I'm hoping someone's been down that road
before and could testify to the possibility...

Thanks,
Christopher
_______________________________________________
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.
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSDocuments without window associations
      • From: Bill Cheeseman <email@hidden>
  • Prev by Date: Re: advice on filtering TreeNode objects
  • Next by Date: Re: Cocoa really needs to be thread-safe
  • Previous by thread: Project Builder's tasty documentation searching
  • Next by thread: Re: NSDocuments without window associations
  • Index(es):
    • Date
    • Thread