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

  • Home
  • SEARCH
  • 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 9221947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:41:54+00:00 2026-06-18T03:41:54+00:00

I use NSFetchedResultsController to fetch from database with Core Data. And I have an

  • 0

I use NSFetchedResultsController to fetch from database with Core Data. And I have an Entity with 2 properties, prop1 and prop2 of NSString.
How would I sort sections not only by one of the properties but both?
Now it is:

Title1ForProp1/Title2ForProp2 (prop1==1 prop2==2)
Title1ForProp1/Title1ForProp2 (prop1==1 prop2==1)
Title2ForProp1/Title1ForProp2 (prop1==2 prop2==1)

I need:

Title1ForProp1/Title1ForProp2 (prop1==1 prop2==1)
Title1ForProp1/Title2ForProp2 (prop1==1 prop2==2)
Title2ForProp1/Title1ForProp2 (prop1==2 prop2==1)
  • 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-18T03:41:55+00:00Added an answer on June 18, 2026 at 3:41 am

    When you create the fetch request for the NSFC you create the sort descriptor and give the request an array.

    You can put as many sort descriptors in the array as you like.

    Just create a sort descriptor for each field you want to sort by.

    I can remember which order you have to put them into the array though.

    OK, so code wise…

    NSSortDescriptor *sd1 = [[NSSortDescriptor alloc] initWithKey:@"prop1" ascending:YES];
    NSSortDescriptor *sd2 = [[NSSortDescriptor alloc] initWithKey:@"prop2" ascending:YES];
    
    [fetchRequest setSortDescriptors:@[sd1, sd2]];
    

    This is all you have to do.

    The NSFC will only split them into sections if you give it a sectionNameKeyPath. If you don’t want any sections then make the sectionNameKeyPath nil.

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

Sidebar

Related Questions

I have an NSFetchedResultsController which I use to fetch my core data and populate
I have recently rewritten my Core Data driven database controller to use Grand Central
I have 2 entities in my Core Data database Person and Photo a Person
I fetch data from a Core Data-base and present them in a UITableView .
I have a list of tasks within Core Data. I fetch them into a
I have a core data model object called Entry. In this I have an
I have an UITableView populated by a NSFetchedResultsController . The initial fetch works fine.
How could I use the NSFetchedResultsController with translated sort key and sectionKeyPath? Problem: I
I'm developing an iPhone application that makes heavy use of Core Data, primarily for
In a UITableViewController , I use an NSFetchedResultsController for my data. Everything works fine,

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.