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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to