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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:45:07+00:00 2026-05-23T12:45:07+00:00

I recently encountered some problems while trying to sort a set of objects. The

  • 0

I recently encountered some problems while trying to sort a set of objects.

The objects I’d like to sort are subclasses of NSManagedObject.
I want to sort the objects by a ‘global_index’, which is, however, not a property in my model. It’s just a getter -(NSInteger)globalIndex {...} each of the objects implements. Inside this method, I do some complex calculation which cannot be done with a simple sort descriptor.

Now, my question: Is there a way to make an NSSortDescriptor sort the objects by the return value of a method?

I really want to use a sort descriptor because it’s (IMO) the only way to make use of NSFetchedResultsController’s cool features. Or is there a way to tell the controller how to sort the fetched objects? Like…
- (NSArray *)sortObjects:(NSSet *)objects {...}

Thanks in advance!

  • 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-23T12:45:08+00:00Added an answer on May 23, 2026 at 12:45 pm

    According to the Core Data Programming Guide,

    The SQL store, on the other hand, compiles the predicate and sort descriptors to SQL and evaluates the result in the database itself. This is done primarily for performance, but it means that evaluation happens in a non-Cocoa environment, and so sort descriptors (or predicates) that rely on Cocoa cannot work. The supported sort selectors are compare: and caseInsensitiveCompare:, localizedCompare:, localizedCaseInsensitiveCompare:, and localizedStandardCompare: (the latter is Finder-like sorting, and what most people should use most of the time). In addition you cannot sort on transient properties using the SQLite store.

    The easy workaround is to save the order with each object (which is a pain when you need to insert an object between two others, but that’s a problem with trying to implement an efficient ordered collection in a database).

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

Sidebar

Related Questions

I've recently set some coursework for some undergraduate students for which they have to
I recently encountered a problem where a value was null if accessed with Request.Form
I recently encountered an odd problem with RSACryptoServiceProvider.VerifyHash . I have a web application
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
Recently, I started changing some of our applications to support MS SQL Server as
While poking around the questions, I recently discovered the assert keyword in Java. At
I've been working with some event handling in Javascript and recently decided to migrate
I'm solving some recurrence relation problems for Big O and so far up till
Recently, I've been running some tests with C++ and VB.NET to compare execution speeds.
I recently encountered a situation where my CouchDB instance used all available disk space

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.