• 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: Re: Sorting NSTableView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Sorting NSTableView


  • Subject: Re: Re: Sorting NSTableView
  • From: malcom <email@hidden>
  • Date: Sat, 29 Jul 2006 15:30:26 +0200

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Sorting NSTableView
      • From: Fredrik Olsson <email@hidden>
References: 
 >Sorting NSTableView (From: malcom <email@hidden>)
 >Re: Sorting NSTableView (From: malcom <email@hidden>)

  • Prev by Date: Re: How to make KVO setup persistent?
  • Next by Date: Core Data and auto increment
  • Previous by thread: Re: Sorting NSTableView
  • Next by thread: Re: Sorting NSTableView
  • Index(es):
    • Date
    • Thread