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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:02:58+00:00 2026-05-23T15:02:58+00:00

I have an entity Order with property paid , which is a boolean. I

  • 0

I have an entity Order with property paid, which is a boolean.

I want to display all orders in a UITableView, but I want to group them in two sections: ‘Not Paid’ and ‘Paid’. So I thought I’d just give “paid” as sectionNameKeyPath, like this:

fetchedResultsController = [[NSFetchedResultsController alloc]
         initWithFetchRequest:fetchRequest
         managedObjectContext:managedObjectContext
           sectionNameKeyPath:@"paid"
                    cacheName:nil];

According to my reasoning, this would result in two sections, where the first section contains all orders with paid = NO (0) and the second section with paid = YES (1).

But when I add a new Order with paid = YES, it shows up in the first section. When I check in the fetched results controller delegate, I can see that a new record with indexPath [0,0] is created! Why doesn’t it get inserted in the second section?

  • 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-23T15:02:58+00:00Added an answer on May 23, 2026 at 3:02 pm

    try adding an array of sort descriptors to the NSFetchRequest that is used with your NSFetchedResultsController.

    You will want to sort on the paid boolean first, then whatever else you want to sort by.

    Swift 3 example:

    fetchRequest = ... // <- instantiate your fetch request
    
    let sortByPaid = NSSortDescriptor(key: "paid", ascending: true)
    let sortByCustomerName = NSSortDescriptor(key: "customer.name", ascending: true) // <- if Order had a relationship to Customer that had an attribute name 
    fetchRequest.sortDescriptors = [sortByPaid, sortByCustomerName]
    
    // now instantiate fetchedResultsController as in the question above
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Entity classes: Order and OrderItem . Order contains a navigation property
I have an abstract entity called Block which contains two attributes: column and order
I have Entity Framework entities Events which have an EntityCollection of RSVP. I want
I have the following entity code, which returns all users and includes all of
I want to search by content on a property in an entity I have
A have two entities. For example timing settings and orders. @Entity public class TimingSettings{
I have an entity that maps to an external oracle table which is one
I have an entity class that has a property with an underlying db column
Say I have an entity MyEntity , and it has a formula-based property fmlaProp
I have a project I am working on that has a Order entity that

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.