Background
I am creating a Source List for my application and I want it structured in a way similar to that of iTunes, with two types of items:
- "Fixed" items – these do not change and can't be moved around – at the top
- Editable items underneath, which can be changed by the user – moved around, renamed etc (in the iTunes example, like Playlists and Smart Playlists)
In my iTunes analogy:
The way I've structured my data so far is as follows:
- The items which I want to be editable are "group" items, in the form of
Group
Core Data entities. - Each item in the Source List is represented as a
SourceListItem
regular Objective-C object so that I can associate each item with a title, icon, child items etc - The fixed items are currently represented by
SourceListItem
instances, stored in an array in my controller object.
The Question
I am unsure of how to amalgamate these two types of item into the Source List, so that the fixed items are at the top and always there and do not change, and the editable items are at the bottom and can be moved around and edited.
These are the ideas I've come up with so far:
Add the fixed items to the Core Data model. This means that I can create an entity to represent Source List items and have my fixed and editable items placed in instances of these. Then these can be bound to the Outline View table column with an Array/Tree Controller. However, this means that I'd have to create a new entity to represent the Source List items, and then sync the
Group
s with this. I'd also have to have some way of creating all the fixed items only once, and if something happened to any of the persistent store files then the fixed items would not be displayed.Merge the fixed items with the group items. Whilst both are stored in separate arrays, this could be done in the controller for my window when the Outline View requests the data (if adopting the
NSOutlineViewDataSource
protocol, not bindings). However this means that I'd have to create newSourceListItem
s for each group in the array controller (to associate each with icons and other attributes), store these and then watch the group array controller for changes to remove, add or modify theSourceListItem
instances when changes are made to the groups.
Does anyone have any better ideas on how I can implement this?
I would like my application to be compatible with OS X v10.5 so I'd prefer any solutions that didn't depend on having Snow Leopard installed.