• 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: Use NSDocument as a variable of another NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use NSDocument as a variable of another NSDocument


  • Subject: Re: Use NSDocument as a variable of another NSDocument
  • From: Quincey Morris <email@hidden>
  • Date: Mon, 18 Jan 2010 13:19:17 -0800

On Jan 18, 2010, at 10:48, Jarod Wen wrote:

> Is it a proper design to use a NSDocument as a variable of another NSDocument?
>
> I am now working on an application which generates some information from a movie. The information generated will be showed as a table, and the information in the table can be saved/opened. Multiple types of information are possible so for one movie there may be several tables.
>
> I used the NSDocument architecture for the movie document, and I am a little bit confused about the hierarchy now: is it possible to set the table as NSDocument and use it as a variable as the movie document? i.e., if I use MovieDocument for the movie and TableDocument for the table, it is ok to use a TableDocument object as a variable of the MovieDocument? Or any better pattern for this?

The question isn't whether one document object can contain a reference to another document object. The question is what's supposed to happen later when the derived (table) document is re-opened.

If the table refers to information in the original (movie) document, you'll need to open the movie document too. That's feasible (though I'd be a little careful about making assumptions about recursion-safety in NSDocumentController methods), but require careful error handling -- what if one document file has moved or disappeared?

OTOH if you have to open both documents together anyway, it sounds like your table perhaps should be *in* the movie document (that is, its data model should be part of the movie document data model) and you should provide multiple window types on the movie document.

So that's the first question you should decide -- whether you really need 2 documents, or whether you need 2 windows onto the same document.


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Use NSDocument as a variable of another NSDocument
      • From: Jeffrey Oleander <email@hidden>
References: 
 >Use NSDocument as a variable of another NSDocument (From: Jarod Wen <email@hidden>)

  • Prev by Date: Re: Keeping closed windows in the Window menu
  • Next by Date: Re: Keeping closed windows in the Window menu
  • Previous by thread: Use NSDocument as a variable of another NSDocument
  • Next by thread: Re: Use NSDocument as a variable of another NSDocument
  • Index(es):
    • Date
    • Thread