• 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: Select model objects with NSTableView using cocoa bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Select model objects with NSTableView using cocoa bindings


  • Subject: Re: Select model objects with NSTableView using cocoa bindings
  • From: Luc Van Bogaert <email@hidden>
  • Date: Thu, 13 Oct 2011 22:44:03 +0200

On 12 Oct 2011, at 23:22, Quincey Morris wrote:

> On Oct 12, 2011, at 13:31 , Luc Van Bogaert wrote:
>
>> I'm wondering if I should create a NSIndexSet property in my model object and bind it to the NSArrayController's 'selectedIndexes' key?
>
> Yes, but you've got the terminology wrong. The relevant concept here is a binding name, and it's "selectionIndexes", not "selectedIndexes". NSArrayController also has a "selectionIndexes" property, but that's what the table view binds to, and is not involved here (except as an "intermediary" property between the table view and the data model -- which is why a NSArrayController is a "mediating" controller.) Also, binding actually goes in the other direction -- you bind the object with the binding (the array controller) to the object with the property (the model). But I'm pretty sure that's what you meant. :)
>

Thanks, I got this working in one 'direction', ie. when the selection in the table is changed, this is reflected in my UI and the 'selected' Dot objects are drawn in a different color. For this, I decided to use a NSMutableIndexSet 'dotSelectionIndexes' property in my model object, bound to the array controller's 'selectionIndexes' binding.

But I'm afraid this still remains a little blurry on how to get the binding work in the other direction. Meaning, I would like to click a Dot object in my UI to select it, and this should change the selection in the table, resulting in turn in the Dot being redrawn with a different color.

I was hoping that by just adding or replacing the contents of my 'dotSelectionIndexes' ivar (hence the choice for a NSMutableIndexSet) with the index of the clicked Dot, would trigger a selection change in the table because of the binding. It seems this doesn't work. So, obviously I'm still missing something.

--
Luc.

_______________________________________________

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: Select model objects with NSTableView using cocoa bindings
      • From: Quincey Morris <email@hidden>
References: 
 >Select model objects with NSTableView using cocoa bindings (From: Luc Van Bogaert <email@hidden>)
 >Re: Select model objects with NSTableView using cocoa bindings (From: Quincey Morris <email@hidden>)

  • Prev by Date: NSArrayController Update Delay
  • Next by Date: Re: NSArrayController Update Delay
  • Previous by thread: Re: Select model objects with NSTableView using cocoa bindings
  • Next by thread: Re: Select model objects with NSTableView using cocoa bindings
  • Index(es):
    • Date
    • Thread