Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 534393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:36:27+00:00 2026-05-13T09:36:27+00:00

I have a NSTableView with 3 columns. I can sort using any of the

  • 0

I have a NSTableView with 3 columns. I can sort using any of the colunms by clicking on the column header. Here is my issue though: I am presorting the array and then loading it in NSTableView so the initial TableView is already sorted by the values in one of the 3 columns. Now when I click on the column headers, i can resort and the small ascending/descending image ( triangle) appears indicating how the sort order is. What I want is, to be able to display this ascendingimage triangle in the column header right at the start when the NSTableView is loaded the first time, for the column based on which I have already sorted the Array. Thanks in advance 🙂

Thanks Peter and cb160. So I added this in my refreshList method:

The *lastColumn parameter has the right identifier if i display it using NSLog, but still that triangle image does not get loaded when the table loads data the first time. Is there something I am missing here ?
My table View is setup like this:

-(IBAction)refreshList:(id)sender
{
//setup array here and sort the array based on one column. This column has 
     identifier 'col1' and it works as expected

    // trying to set the sortindicator image for the column here
    NSTableColumn *lastColumn;

lastColumn = [aTableView tableColumnWithIdentifier:@"col1"];
[aTableView setIndicatorImage:[NSImage imageNamed:@"NSDescendingSortIndicator"]     
inTableColumn:lastColumn];
[aTable reloadData];
 } 

 - (int) numberOfRowsInTableView:(NSTableView *)aTable
{ // return count of array
 }

- (id)tableView:(NSTableView *)aTable objectValueForTableColumn: (NSTableColumn *)          
   tableColumn row:(int)row
  { 
   //set up arrays here to load data in each column


  }
- (void)tableView:(NSTableView *)aTableView sortDescriptorsDidChange:(NSArray   
  *)oldDescriptors
{
//sort here when column headers are clicked
} 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:36:27+00:00Added an answer on May 13, 2026 at 9:36 am

    You can use the -setIndicatorImage:inTableColumn: method on NSTableView to do this.

    You can use the strings NSAscendingSortIndicator and NSDescendingSortIndicator to use the built in images (with UIImage‘s +imageNamed: method.)

    You can get the NSTableColumn * parameter for this method using the -tableColumnWithIdentifier: method on NSTableView. Set the idenitfier in the column using the identifier attribute in Interface Builder (see below)

    Xcode interface builder screenshot

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a NSTableView with multiple columns. clicking each of the columns sorts by
I have a NSTableView that is bound using Cocoa Bindings. One column of that
i have NSTableView and two columns in it: NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@custId]
I want to sort an NSTableView column with IPv4 addresses using an SortDescriptor. This
I have NSTableView with two columns, and i wanna fill them entries from SQLite
I have an NSTableView that contains a few columns that are populated with data.
I have an NSTableView that is done using the typical IB and data bindings.
I have an NSTableView that has 2 columns, one for an icon and the
I have an NSTableView with 4 columns. I also have a custom background color
I have an NSTableView with 4 columns. I want to change the auto resizing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.