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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:42:41+00:00 2026-06-05T14:42:41+00:00

In my app, I have a task list (no, it’s not just another todo

  • 0

In my app, I have a task list (no, it’s not just another todo app), and I display the tasks in a UITableView using an NSFetchedResultsController. Here is the relevant initialisation code:

NSSortDescriptor *dueDateSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"due" YES];
NSSortDescriptor *completionSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"completed" ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObjects:completionSortDescriptor, dueDateSortDescriptor, nil]];

_fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:context sectionNameKeyPath:@"completed" cacheName:nil];

What this does is sorts the tasks such that I have an incomplete tasks section at the top, sorting with the tasks due first on top, and tasks due later further down. This all works.

However, this means that the second section, the one with the completed tasks, also sorts this way, so the earliest due tasks are on top. What I want to do is change it so the second section sorts the other way around (in descending order), but the first section stays sorted in ascending order. Is this even possible? How would I go about this?

Why I want to do this: The way it currently works, the tasks at the top of the second section (and therefore the most visible) are the ones that were completed ages ago. It is more likely that the user would want to see the tasks that are more recently completed (and uncheck one if it was accidentally checked), and presumably the tasks with a more recent due date were more recently completed. I am happy to add a separate completion date field to the Core Data task object if necessary (This isn’t a shipping application yet, so I can change the data format however I like).

  • 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-05T14:42:43+00:00Added an answer on June 5, 2026 at 2:42 pm

    This is not possible when using an NSFetchedResultsController. You’d have to manually fetch your data and implement UITableView’s delegate methods.

    EDIT: Whoah, my mistake, there’s a fairly easy solution for this. Set two sort descriptors:

    • The first one for completedDate (descending). This field is the same (nil) for all incomplete tasks.

    • Add a second one for addedDate (ascending). It will sort by completed date (newest first), but in the first section you won’t have any completedDates, so it will then use the added date (oldest first).

    For the second section, it will just use completedDate (newest first), so there you go.

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

Sidebar

Related Questions

in my android app i am using expandable list view to display some text.These
On my rails app I have a list of items (like a task list)
In my app I have a notification in the task bar and when clicked
This is a continuation of the question here: JBoss - does app have to
In one app, I have a task to create files that will be used
I have an App which has a Tasks tab and a Projects tab. I
I have a rake task that uploads a list of files via ftp. Copying
I'm developing for Android and I have an app (called Forget-Me-Not) that uses a
I'm trying to get my TODO comments to show up in the task list
I'm using JPA with with Google App Engine. Let's say I have a very

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.