• 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: Getting an NSOutlineView Item's parent
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting an NSOutlineView Item's parent


  • Subject: Re: Getting an NSOutlineView Item's parent
  • From: Perrog <email@hidden>
  • Date: Wed, 18 Oct 2006 19:11:43 +0200

You normally retrieve the parent item from your own data model. The
"item" input to objectValueForTableColumn isn't retained by
NSOutlineView so it might be invalid if you don't manage it yourself.
I think you are "abusing and not using" the NSOutlineView.

However, to compute the parent item, you can start at the row previous
to the item, and decrement the row count, checking if the previous
item is expandable and if it is expanded. If that is the case, then it
is the parent. (This idea comes from my way of saving the ouline view
state and not actually used to retrieve the parent item.)

for( int row = [outlineView rowForItem:theItem] - 1; row >= 0; --row ) {
	id item = [outlineView itemAtRow:idx];
	if( item == nil ) {
		return gRootItem; // the root parent
	}
	if( [outlineView isExpandable:item] == YES && [outlineView
isItemExpanded:item] == YES) {
        // item is the parent for theItem
	} else {
		// item is sibling for theItem
	}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Re: Getting an NSOutlineView Item's parent
      • From: "Alan Smith" <email@hidden>
References: 
 >Getting an NSOutlineView Item's parent (From: The Beerbowers <email@hidden>)

  • Prev by Date: Re: How to get hyperlink in a html file?
  • Next by Date: -[NSURLResponse expectedContentLength] returns -1
  • Previous by thread: Re: Getting an NSOutlineView Item's parent
  • Next by thread: Re: Re: Getting an NSOutlineView Item's parent
  • Index(es):
    • Date
    • Thread