Note that there are some explanatory texts on larger screens.

plurals
  1. POModeling user-orderable lists with Core Data / Bindings
    primarykey
    data
    text
    <p>I'm working through a learning project around Core Data on OS X. I have an entity (Foo) in the data store, and in the UI, I use an NSArrayController with bindings to put some (name) field of the Foo objects into an NSTableView, where the user can add/delete/rename (and potentially reorder) the items.</p> <p>As you know, Core Data storage is unordered. However, I'd like to give it order from the user standpoint. E.g. adding a new row to the table view fixes that new Foo to the end of the list, etc. If the table allows reordering, that order is maintained.</p> <p>I assume that I should accomplish this by adding some hidden (ie the user never encounters it) "ordinal" field to the Foo entity, which is fine. I'm trying to figure out:</p> <ol> <li>Where is the right place to set this "ordinal" field for new items? Right now, a button is invoking the <code>add:</code> action on the array controller and bindings handles all the rest magically. (I'll need access to the count of items to set it correctly.)</li> <li>Where is the right place to fixup the whole result set's ordinals on delete or reorder?</li> <li>Assuming all objects in the store have a reasonable ordinal attribute, what must I do to the UI connections to get the table view to display the results sorted by that ordinal? Is this something I can do purely with bindings? Do I need to subclass... something? </li> </ol> <p>It feels like this is a common enough scenario that people here might have a ready answer. I'm new to Core Data and bindings-- trying to grope my way around. Don't need code; pointers in the right direction would be great. Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload