Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Sorting NSTableView



Damn this is a wonderful thread!
Ok I've found the solution. This is the method used when user click on
outlineview header:

- (void)outlineView:(NSOutlineView *)outlineView
mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn {

   if (lastColumn == tableColumn) {
       // User clicked same column, change sort order
       sortDescending = !sortDescending;
   } else {
	        // User clicked new column, change old/new column headers,
       // save new sorting selector, and re-sort the array.
       sortDescending = NO;
       if (lastColumn) {
           [self setIndicatorImage: nil
               inTableColumn: lastColumn];
       }
	}
       lastColumn = [tableColumn retain];
       [self setHighlightedTableColumn: tableColumn];
		
		[listOfMsg sortUsingSelector: [[tableColumn sortDescriptorPrototype]
selector]];
		if (sortDescending) [self reverse: listOfMsg];
		
   [self reloadData];
}

- (void)reverse:(NSMutableArray *) _list {
	int i;

	for (i=0; i<(floor([_list count]/2.0)); i++) {
		[_list exchangeObjectAtIndex:i withObjectAtIndex:([_list count]-(i+1))];
	}
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >Sorting NSTableView (From: malcom <email@hidden>)
 >Re: Sorting NSTableView (From: malcom <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.