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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:23:40+00:00 2026-06-09T18:23:40+00:00

I have a table view that displays a musician’s albums. Each section is an

  • 0

I have a table view that displays a musician’s albums. Each section is an Album, each row is a Track. I need the albums/sections sorted by release date, then by title. I’m pulling the tracks from Core Data like so:

fetchRequest = [[NSFetchRequest alloc] init];
...
fetchRequest.sortDescriptors = [NSArray arrayWithObjects:
                                [NSSortDescriptor sortDescriptorWithKey:@"album.releaseDate" ascending:YES],
                                [NSSortDescriptor sortDescriptorWithKey:@"album.title" ascending:YES],
                                [NSSortDescriptor sortDescriptorWithKey:@"trackNumber" ascending:YES],
                                nil];
frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest
                                          managedObjectContext:context
                                            sectionNameKeyPath:@"album.releaseDate" // <-- PROBLEM HERE
                                                     cacheName:nil];

This doesn’t work because two albums with the same release date will appear in the same section.

If I use album.title as the sectionNameKeyPath, hell breaks loose because the sections are sorted alphabetically, then imposed on the tracks (which are sorted by date, title, trackNumber).

How do I sort the sections by date, then by title?

  • 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-09T18:23:41+00:00Added an answer on June 9, 2026 at 6:23 pm

    From what I’ve read, this single-property sorting is just something we have to live with on iOS. So I added a transient property to Album that acts as a sort key for both properties:

    - (NSString *)sortKeyDateTitle
    {
        [self willAccessValueForKey:@"sortKeyDateTitle"];
        NSString *sortKey = [NSString stringWithFormat:@"%@%@", self.releaseDate, self.title];
        [self didAccessValueForKey:@"sortKeyDateTitle"];
        return sortKey;
    }
    

    It produces strings like this:

    1954-04-01 06:00:00 +0000A Night At Birdland, Vol. 1
    1954-04-01 06:00:00 +0000A Night At Birdland, Vol. 2
    

    It works, but converting from date to string for sorting seems stupid. I’m waiting for something better.

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

Sidebar

Related Questions

I have setup a table view that displays users albums from the device. I'm
I have a view that displays a table: rows represent days - one row
On each cell of my table view I want to have a bar that
I have a table view that displays dates using a NSDateFormatter to format them
I have a table view that displays a list that I want the user
I have a custom Table View Cell that displays the details of a Conference
I have a table view that displays a list of users. The avatar images
I have a table view that displays managed objects (Tasks). I'd like to fetch
I have a table that displays a list of companies. Each time a company's
I have a table view that displays custom cells, the cells contain an image

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.