On Feb 19, 2011, at 20:00, Peter Zegelin wrote:

> I  have several tables showing the same data that need to stay in synch. The 
> tables are instantiated via the same nib so they are identical. The tables 
> get their data through an array controller bound to an array in a shared 
> object and their selection stay in synch by the array controller being bound 
> to an NSMutableIndexSet in the same shared object. After a bit of fooling 
> around I also managed to get the table sorting also in synch but how it works 
> seems a bit strange.
> 
> I eventually created an array of sort descriptors in the shared object and 
> bound the Array Controller to that. There is only one descriptor in the 
> array. The table in turn is bound to the sortDescriptors Controller Key of 
> the Array Controller. This all works except for the fact that there is only 
> one sort descriptor but several table columns and they all sort as well. 
> Indeed I commented out the actual creation of the sort descriptor in the 
> shared object and it still sorts on all columns.
> 
> Does anyone know what may be going on and what is the correct way to do 
> synchronised sorting via bindings?

If you sort on a column in the table view itself (by clicking the column header 
-- which is what I assume you mean by "several table columns ... they all sort 
as well"), then that changes the sort descriptor array, a change which the 
bindings you've described will push back to your model.

Chances are you've accidentally allowed your data model sort descriptors 
property be settable. (What happens when it's not, and the table view tries to 
change the sort descriptors, I don't know -- maybe an exception, maybe a 
harmless error in the log, maybe it's silently ignored.) You should probably 
make sure the property isn't settable (pay attention to 
+accessInstanceVariablesDirectly).

If you don't want the bindings to attempt to change your sort descriptors, you 
should turn off the "sortable" property in each table column.


_______________________________________________

Cocoa-dev mailing list ([email protected])

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 [email protected]

Reply via email to