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 7006687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:30:33+00:00 2026-05-27T21:30:33+00:00

I have fetched some records from core data, and presented it in a table

  • 0

I have fetched some records from core data, and presented it in a table view. All of these records have 11 properties. Now in my tableview presentation, on header I have added a button for all of these properties. On clicking of the button, I want to sort the records on the basis of that property.
I tried using sort descriptor, but it doesn’t work.
My code is like this:-

- (IBAction)sortButton:(id)sender {
// tags are from 100 to 111
UIButton *sortButton = (UIButton*)sender;
NSString *sortDescriptorKey = nil;
// create sort descriptor key according to the tag value
if (sortButton.tag == 100 )  sortDescriptorKey = [NSString stringWithString:@"reportID "];
....
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:sortDescriptorKey ascending:YES];
[self.recordArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
[sortDescriptor release];
[self.tableView reloadData];
}

But, this code does not change any ordering at all.
Am I missing anything, or is there is another way of doing it.

  • 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-27T21:30:34+00:00Added an answer on May 27, 2026 at 9:30 pm

    The problem lies in this statement

    [self.recordArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
    

    This returns a sorted copy of recordArray, but you are not using it. You should assign it back to recordArray so that the tableView is correctly updated when it is reloaded. Change it to:

    self.recordArray=[self.recordArray sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDescriptor]];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some Core Data entries which are all fetched and thrown into an
I have fetched some 1000 records using data adaptor and displayed in the UI(DataGrid).
I have an activity which displays some data fetched from the server. If no
I have a function which performs some operation i.e. fetches some data from database.
I have a silverlight 3 application, that fetches some simple data from a ms-sql-server
I have some 30,000 records in my Raw_deals table and some raw_cities table has
We have some lists of data being fetched in our application via a SqlCommand
I have a repeater which fetches data from a database and shows some labels
I have a list with some strings (most of which I fetched from a
I have this code that fetches some text from a page using BeautifulSoup soup=

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.