• 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
Why did I prefix the key of an NSSortDescriptor with "@"?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Why did I prefix the key of an NSSortDescriptor with "@"?


  • Subject: Why did I prefix the key of an NSSortDescriptor with "@"?
  • From: Jerry Krinock <email@hidden>
  • Date: Tue, 25 Jul 2006 12:51:12 -0700
  • Thread-topic: Why did I prefix the key of an NSSortDescriptor with "@"?

I'm trying to re-use some code I wrote a few months ago for
tableView:didClickTableColumn.  This method sorts the clicked column and
flips the up/down triangle.

I notice that, for some reason which I cannot remember but vaguely recall
activated some semi-secret feature, I prefixed the character "@" onto the
tableColumn's identifier (string) before passing it as the key to to
NSSortDescriptor's initWithKey:ascending method.

I cannot find any notes or any mention of that "@" in searching
documentation today.  Am I imagining things?

Jerry Krinock

- (void)tableView:(NSTableView *)tableView
  didClickTableColumn:(NSTableColumn *)tableColumn {

   //*** Here is where I add the prefix:****************
   NSString* key = [NSString stringWithFormat:@"@%@",
                        [tableColumn identifier]] ;

    BOOL ascending ;

    NSImage* currentImage =
    [tableView indicatorImageInTableColumn:tableColumn] ;

    if (currentImage == [NSImage imageNamed:@"NSAscendingSortIndicator"]) {
        [tableView setIndicatorImage:[NSImage
              imageNamed:@"NSDescendingSortIndicator"]
                       inTableColumn:tableColumn] ;
        ascending = NO ;
    } else {
        [tableView setIndicatorImage:[NSImage
              imageNamed:@"NSAscendingSortIndicator"]
                       inTableColumn:tableColumn] ;
        ascending = YES ;
    }

   //*** Here is where I use it: ***************
    NSSortDescriptor* descriptor = [[NSSortDescriptor alloc]
                               initWithKey:key ascending:ascending] ;
    NSArray* descriptors = [NSArray arrayWithObject:descriptor] ;

    NSArrayController* arrayController = [self arrayController] ;
    [arrayController setSortDescriptors:descriptors] ;
    [table reloadData] ;
    [table selectRowIndexes:[arrayController
             selectionIndexes] byExtendingSelection:NO] ;

    [descriptor release] ;
}



 _______________________________________________
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: Why did I prefix the key of an NSSortDescriptor with "@"?
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: Re: ZIP archives
  • Next by Date: Re: -stringValue on NSTextfield does not reflect actual contents [SOLVED]
  • Previous by thread: Re: ZIP archives
  • Next by thread: Re: Why did I prefix the key of an NSSortDescriptor with "@"?
  • Index(es):
    • Date
    • Thread