Easy way to reorder Core Data objects that use an 'order' attribute, bindings and NSTableView compatible
| Originator: | amorya | ||
| Number: | rdar://13234894 | Date Originated: | |
| Status: | Resolved: | ||
| Product: | Mac OS X SDK | Product Version: | 10.8 |
| Classification: | Enhancement | Reproducible: | Not Applicable |
It takes a lot of boilerplate code to implement drag-reordering in an NSTableView that is backed by bindings/Core Data. There are a bunch of ways to implement ordering in Core Data, such as ordered relationships. The method I'm interested in is where an 'order' attribute is included in the entity. I'd like the NSArrayController to have a field in the inspector in Interface Builder, into which you can put the name of your ordering attribute. If you do that, it firstly configures the sort descriptors for the NSArrayController automatically, and secondly it enables the NSArrayController to handle reordering. When reordering happens, the values of the ordering attribute are renumbered to match the new order. The final piece in the puzzle is making sure NSTableView, if bound to an NSArrayController that has an ordering attribute name filled in, communicates with the NSArrayController to tell it to reorder the items when a drag happens.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!