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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:50:45+00:00 2026-06-18T05:50:45+00:00

I have a Table View Controller with a list of Formations handled by a

  • 0

I have a Table View Controller with a list of Formations handled by a fetchResultsController.

Here’s how my core data entities looks like :

enter image description here

I try to sort my fetchResultsController by dateRangelike this :

// |fetchedResultsController| custom setter
- (NSFetchedResultsController *)fetchedResultsController {
    if (_fetchedResultsController != nil) {
        return _fetchedResultsController;
    }

    _fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:self.fetchRequest managedObjectContext:self.mainManagedObjectContext sectionNameKeyPath:@"dateRange" cacheName:kFormationsFetchedCacheName];
    _fetchedResultsController.delegate = self;

    return _fetchedResultsController;
}

// |fetchRequest| custom setter
- (NSFetchRequest *)fetchRequest {
    if (_fetchRequest != nil) {
        return _fetchRequest;
    }

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"student == %@", self.currentStudent];
    NSSortDescriptor *dateDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateRange" ascending:NO];
    NSSortDescriptor *nameDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:NO];

    _fetchRequest = [[NSFetchRequest alloc] initWithEntityName:kBSFormation];
    _fetchRequest.predicate = predicate;
    _fetchRequest.sortDescriptors = [NSArray arrayWithObjects: dateDescriptor, nameDescriptor, nil];

    return _fetchRequest;
}

Everything is fine when i try to add the very first Formation, but for the next ones, i have these errors:

2013-01-30 22:43:08.370 [7202:c07] -[BSDateRange compare:]: unrecognized selector sent to instance 0x81781a0

2013-01-30 22:43:08.371 [7202:c07] CoreData: error: Serious application error.  Exception was caught during Core Data change processing.  This is usually a bug within an observer of NSManagedObjectContextObjectsDidChangeNotification.  -[BSDateRange compare:]: unrecognized selector sent to instance 0x81781a0 with userInfo (null)

2013-01-30 22:43:08.372 [7202:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BSDateRange compare:]: unrecognized selector sent to instance 0x81781a0'

If i comment this line : NSSortDescriptor *dateDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"dateRange" ascending:NO];, it’s working but my table view is messy as the sectionNameKeyPath is set to dateRange

Someone is figuring out what’s the problem here ? :/

  • 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-18T05:50:46+00:00Added an answer on June 18, 2026 at 5:50 am

    You’re telling it to sort based on the dateRange relationship. But dateRange is a relationship to BSDateRange, and how does Core Data compare those? Should it use from, or maybe to, or some combination of those? You can’t just tell it to sort on an object like that, because it’s not obvious how sorting should work.

    Instead, first figure out what sorting even means. Then modify your sort descriptor appropriately. For example if you decide that sorting depends on the from value, change the sort descriptor to use the key path to from:

    NSSortDescriptor *dateDescriptor = [NSSortDescriptor
        sortDescriptorWithKey:@"dateRange.from"
        ascending:NO];
    

    If you need to sort based on both from and to, use more than one sort descriptor.

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

Sidebar

Related Questions

Using storyboards I have a table view controller with a list of rows. When
I have a table view controller which list the contents of an entity in
I have a table view controller with (among others) a cell that is to
I have a Table View Controller with cells. I want to update the text
I have a table view controller with custom cells. In those cells i added
I have a table view controller which doesn't let me manually scroll to the
Using storyboard, I have a table view controller containing multiple dynamic prototype cells. One
I have view controller, into the view i have put a table view, and
I have a categories table view controller. In my app, categories can have subcategories.
I have created a table view with navigation controller. I want to link table

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.