• 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: what do I need the NSArrayController for?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what do I need the NSArrayController for?


  • Subject: Re: what do I need the NSArrayController for?
  • From: Seth Willits <email@hidden>
  • Date: Wed, 02 Apr 2014 09:22:05 -0700

On Apr 2, 2014, at 6:54 AM, Roland King <email@hidden> wrote:

> At this point I realized the NSArrayController was doing nothing. ... I took it out and bound direct to the equivalent properties on the model....

It's not doing nothing.

The NSArrayController doesn't simply "forward" objects from the model to the tableview, it has its own copy of the array (the arrangedObjects) which keeps it separate the model.

Normally your controller object would have its own copy of the devices array, be the delegate and data source for the tableview, providing the filtered and sorted data to the tableview, handle the selection notifications and update things. Not to mention listen to when the source devices array changes to get a new copy of it.

NSArrayController does all of that for you, without interfering with your model.

By binding the table view to the model properties directly, you've now established that no other tableview or any other object can have its own selection, or order for those objects. You can't sort or filter the tableview without sorting or filtering the model data itself, which is most often a bad idea.

As for the selection property on your model, you can easily listen to either the tableview or the array controller's selection changing, and set the property yourself. You're not required or expected to binding everything just because you can in some manner.


--
Seth Willits




_______________________________________________

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: what do I need the NSArrayController for?
      • From: Roland King <email@hidden>
References: 
 >what do I need the NSArrayController for? (From: Roland King <email@hidden>)

  • Prev by Date: Re: what do I need the NSArrayController for?
  • Next by Date: Re: what do I need the NSArrayController for?
  • Previous by thread: Re: what do I need the NSArrayController for?
  • Next by thread: Re: what do I need the NSArrayController for?
  • Index(es):
    • Date
    • Thread