• 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: Advise on referencing NSDocument from custom view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Advise on referencing NSDocument from custom view


  • Subject: Re: Advise on referencing NSDocument from custom view
  • From: Quincey Morris <email@hidden>
  • Date: Sun, 10 Aug 2014 14:05:45 -0700

On Aug 10, 2014, at 13:16 , Luc Van Bogaert <email@hidden> wrote:

> Let's see if I understand this correctly: do you mean I could create a separate model class, eg. "Drawing" with all of it's properties and reference this in my document class as an instance variable or even as a property.
> Then, from my custom view, instead of using [[self.window.windowController document] someProperty]', I could use '[self.window.windowController someProperty]', which in turn would message my model object to return the value of 'someProperty' using 'return [self.document someProperty]' ?

To be specific:

In a document-based app, I will generally have MyDocument, MyWinController and MyModel.

MyDocument has a MyModel property, referencing the model that it loaded from the document file (or whatever).

MyWinController has a MyModel property, referencing the same model as the document.

A custom MyView would also have a MyModel property referencing the same model, initialized in any of various ways depending on how the view was created. The view would then use myModel.someProperty whenever it needed it, perhaps even binding to it.

Putting a derived “someProperty” directly on the window controller, or even on a view controller, *is* feasible too. Often, I find, I use this approach when the view presents a somewhat transformed picture of the data model. Databasey kinds of apps (such as master/detail) often seem to want to use the real data model directly. UIey kinds of apps often seem to want to use a transformed model.

_______________________________________________

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


References: 
 >Re: Advise on referencing NSDocument from custom view (From: Quincey Morris <email@hidden>)

  • Prev by Date: NSTableRowView appearance when group rows float
  • Next by Date: Re: NSTableRowView appearance when group rows float
  • Previous by thread: Re: Advise on referencing NSDocument from custom view
  • Next by thread: Re: Advise on referencing NSDocument from custom view
  • Index(es):
    • Date
    • Thread