On Feb 2, 2010, at 8:46 PM, Poonam Virupaxi Shigihalli wrote:

> I have an outlineview to display n number of groups(Example: Grp1, Grp2 etc), 
> each can have n number of items, same item can be present in many groups.
> Suppose item1 is present in Grp1 and Grp2, if i have to delete item1 in Grp1, 
> i have to access the parent object i.e Grp1.
> But when i return parent object  it always returns recent parent object i.e 
> Grp2.

NSOutlineView doesn't care about parent objects. If your own data model needs 
multiple parent objects, then what you have isn't a tree, it's a directed 
acyclic graph (DAG). Any algorithms or data structures textbook will describe 
those and how to implement them.

> Following is my implementation:

Well, you're showing a single method, that returns the values to display in the 
outline view. You'll need more than that to implement it.

>    if ([[[tableColumn headerCell] stringValue] compare:@"Key"] == 
> NSOrderedSame)

Don't use column titles or header titles to identify columns. Otherwise your 
code will break when the app is localized into French and the title of the 
column is now "Clef". Use the column's identifier property instead; that's what 
it's for.

Also, you can just use -isEqualToString: to compare strings for equality 
instead of compare:.

>                                return [NSString stringWithFormat:@" All"];

You don't need stringWithFormat there since there's no formatting being done. 
Just return @" All".

>        [outlineview reloadData];

Yikes — you should never call that in this method. All you're supposed to be 
doing is telling the outline view what to display in a cell. Forcing a reload 
at this point could really confuse it.

In general, this method doesn't make much sense to me. Have you looked at 
Apple's outline sample code like DragDropOutlineView? It might give you a 
better idea how this stuff works.

—Jens_______________________________________________

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