• 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: Sorting using NSOutlineView, NSTreeController and NSArray / NSMutableArray
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sorting using NSOutlineView, NSTreeController and NSArray / NSMutableArray


  • Subject: Re: Sorting using NSOutlineView, NSTreeController and NSArray / NSMutableArray
  • From: George Orthwein <email@hidden>
  • Date: Fri, 28 Apr 2006 12:56:04 -0400

On Mar 11, 2006, at 7:31 PM, Alexander Hartner wrote:
I found my error. I also had the count key path linked in IB. Once I removed the association I was able to sort the view.


I was having the exact same problem... only I didn't want to remove the Count Key Path because it solves the "index beyond bounds" error for me.
http://www.cocoabuilder.com/archive/message/cocoa/2005/11/9/149863


My NSOutlineController/NSTreeController setup is based off of Matt Holiday's DragAndDropOutlineEdit. I added an NSArrayController set to Entity and bound to the MOC. I then bound its sortDescriptors to the NSTreeController's sortDescriptors. What's interesting is that I could see that the NSArrayController sort was actually being affected by column clicking in the NSOutlineView (because I have a custom view bound to the NSArrayController)... but the NSOutlineView wasn't showing the sort itself! Removing the count key path allowed the NSOutlineView to sort.

Anyway, I solved it with:

- (void)outlineView:(NSOutlineView *)outlineView didClickTableColumn: (NSTableColumn *)tableColumn
{
[outlineTreeController rearrangeObjects];
}


And now I can keep the Count Key Path. Not sure why the Count Key Path would affect this...

---

Also, I was wondering if there was a simpler way of specifiying Count Key Path using a collection operator. I tried "children.@count" with no success. For now I'm using a method in my NSManagedObject subclass:

-(int)childCount
{
	return [[self valueForKeyPath:@"children"] count];
}


Thanks, George _______________________________________________ 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
  • Prev by Date: Re: OT: folder guards????
  • Next by Date: Re: added table column won't show because of autosaving
  • Previous by thread: Re: OT: folder guards????
  • Next by thread: Binding Text Field to Show Time Interval?
  • Index(es):
    • Date
    • Thread