I have a core-data app, with a view that shows a managed object, along with an 
NSCollectionView displaying related managed objects in 1 column, all hooked 
together primarily with bindings.

This works fine (selecting different objects automatically updates the 
collectionview and I can add/edit/delete related objects).

However, I would like to present the related records in the same order each 
time, as well as have new objects appear in a predicable location (namely, at 
one 'end' of the collectionview.  I have an 'order' attribute, with NSInteger16 
values, that I want to sort on.

Just adding a NSSortDescriptor to the NSArrayController that the 
NSCollectionView gets it's managed objects from only partially works:

1) it ONLY does the sort if I have a button that changes the sort AFTER the 
array is fully populated.  Setting the sortDescriptor on the NSArrayController 
when the view loads, or even as the root managed object is changed, doesn't 
result in the collectionview being sorted

2) adding or deleting a related record [removing/adding objects for the 
collectionview] randomizes the order of the objects presented in the 
collectionview [either by calling add: on the NSArrayController or directly 
creating a new NSManagedObject for the relation].  The object is 
presented/removed, but the order is always rearranged randomly.

I've even tried (programmatically):
-add/delete record
-clear sort descriptor
-set sort descriptor

and it does do the sort.  It only applies the sort if I hit a button that 
changes the sortDescriptor on the NSArrayController AFTER the collectionview 
gets fully populated.

Any ideas on the best way to keep the nsarraycontroller and/or the 
nscollectionview sorted all the time?

Eli


_______________________________________________

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