• 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: Best data source for table view in document window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Best data source for table view in document window


  • Subject: Re: Best data source for table view in document window
  • From: Andy Lee <email@hidden>
  • Date: Wed, 05 Sep 2012 16:46:47 -0400

On Sep 5, 2012, at 11:24 AM, Kyle Sluder <email@hidden> wrote:
> On Sep 5, 2012, at 5:39 AM, Jerry Krinock <email@hidden> wrote:
>
>> What is the best the data source for a table view in a document window?  The candidates are…
>>
>> (1)  Category of the document.  This is the way it is done in the WithoutBindings ("With and Without Bindings") Apple sample code.  But it seems like too much "view-ish" code in the data model, particularly when my document class is also used in a GUI-less command-line tool, which has no need for this code.
>
> NSDocument is really a controller.

Yup, and a data source is by nature a controller object: it mediates between a view (see the first argument to each data source method) and a model. Your document, your window controller, or a view controller would all be good candidates to be data sources.

>> (4)  Category of the table view itself, assuming that it is subclassed.  Seems like a logical division.  No worrying about whether table view or its data source gets deallocced first.  Access the document via [[[self window] windowController] document].
>
> Absolutely, completely, 100% not. Never ever do this. If NSTableView privately implements any methods that it also expects the data source to implement, you will get bad behavior.

Not only that, you'd be putting controller-ish stuff (and, by necessity, model-ish stuff) into the view. The point of a data source is like the point of a delegate: so you can customize an object's behavior without having to subclass and without violating MVC.

--Andy


_______________________________________________

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: 
 >Best data source for table view in document window (From: Jerry Krinock <email@hidden>)
 >Re: Best data source for table view in document window (From: Kyle Sluder <email@hidden>)

  • Prev by Date: Re: Best data source for table view in document window
  • Next by Date: CA_DEBUG_TRANSACTIONS=1
  • Previous by thread: Re: Best data source for table view in document window
  • Next by thread: Re: Best data source for table view in document window
  • Index(es):
    • Date
    • Thread