• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOutlineView parentobject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView parentobject


  • Subject: Re: NSOutlineView parentobject
  • From: Jens Alfke <email@hidden>
  • Date: Tue, 2 Feb 2010 22:53:44 -0800

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >NSOutlineView parentobject (From: "Poonam Virupaxi Shigihalli" <email@hidden>)

  • Prev by Date: Re: Rosetta Quandry
  • Next by Date: Re: How to upload a picture or movie existed in the iphone to a given server?
  • Previous by thread: NSOutlineView parentobject
  • Next by thread: NSOutlineView parentobject
  • Index(es):
    • Date
    • Thread