On Sep 30, 2009, at 20:58, Rick Mann wrote:


On Sep 30, 2009, at 16:22:45, Rick Mann wrote:

I'm looking at ways of grouping some Core Data objects in a outline view. What I have are 3 or 4 different entities, and I want each of the objects of each type to appear under a parent item in the outline view.

Currently, I've implemented a simple table view and it's bound to an array controller that gets the objects from Core Data. Now I want to expand that same list to handle the other objects, so an outline view seems natural, with the top level nodes corresponding to the various types of entities, and the entities existing below.

Since the model doesn't have any notion of groups, I'd like to programmatically create the top entities, and have core data manage the children of each. Is this even possible?

Do you think I could create an plain Obj-C object with appropriate accessors to act as my grouping object, and then have it implement Core Data fetch operations to return the children? I don't know, though, how to get changes in the managed object context to be automatically reflected in the tree view using this technique. I'm sure there's some observer/key notification thing to set up, but I'm not very fluent in the programmatic aspects of that stuff.

I was thinking about something similar. I guess you would need to encapsulate an arbitrary number of NSTreeController objects in a custom object that behaves like an NSTreeController. I have decided against it thought because I am quite convinced it would be a *lot* more difficult to do properly (even if it is possible) then to implement a custom NSOutlineViewDataSource.

Still, you might be able to use NSTreeControllers as a starting point in your data source, which should make it easier to observe records being created / deleted / modified. Hm, it might be a better idea to use NSArrayControllers for each of your entities and observe those instead.

Another option is to simulate this in the GUI using a number of NSOutlineViews each wired separately. You would need to synchronize selections between them though. And you would need to deal with sizes / positioning manually. This might be a *bit* easier, but like with every hack: expect problems.

I think that your best option is to sit down, dig through the relevant technologies, and do it. I don't think there's an easy way to accomplish this.

F
_______________________________________________

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