Re: Sorting using NSOutlineView, NSTreeController and NSArray / NSMutableArray
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