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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T09:08:15+00:00 2026-06-10T09:08:15+00:00

It appears NSSortDescriptor should be a fairly easy class to work with. I have

  • 0

It appears NSSortDescriptor should be a fairly easy class to work with.

I have stored in CoreData an entity with an attribute of type NSDate appropriately named @”date”. I am attempting to apply a sort descriptor to a NSFetchRequest and it doesn’t appear to be returning the results I had hoped for.

The result I am hoping for is to simply arrange the dates in chronological order, and instead they are returned in the order for which they were added to CoreData.

Perhaps you can offer guidance?

Is the parameter ‘ascending’ what controls the sort?

Some Code:

NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entityDesc = [NSEntityDescription entityForName:@"Data" inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entityDesc];

[fetchRequest setFetchBatchSize:10];

NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];    

[fetchRequest setSortDescriptors:sortDescriptors];

NSArray *fetchedObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
  • 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-06-10T09:08:16+00:00Added an answer on June 10, 2026 at 9:08 am

    Separate sort routines (functions or blocks) look like overkill to me. I am routinely sorting Core Data entities by date attribtues just with the sort descriptor method you show in your code. It works perfectly every time.

    Clearly, there must be some other mistake.

    • Check if the type is set correcly in your managed object model editor, and in the class file (Data.h, in your case).
    • Also, check if you are not manipulating this attribute so that the creation order ensues.
    • Also, make sure you are not mixing up this attribute with another attribute of type NSDate.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It appears that MySQL doesn't have array variables. What should I use instead? There
It appears that this: var img = document.createElement(img); img.setAttribute(class, check); doesn't work in IE7,
It appears that when I do git stash apply, I need to then type
Appears that java's sound API's work well for single streams, and even for setting
It appears that to use Google Translate you have to use an API key
It appears to me that Django and Pylons have different ideas on how middleware
There appears to be no easy answer to this, but are there any assumptions
I have entity LoginPass with strings login and pass. I created registration, and now
It appears Onclick events are not processed for menu items that have sub-items. I
It appears that when you type in a number in Java, the compiler automatically

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.