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

The Archive Base Latest Questions

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

Sort descriptors with custom blocks are not supported in iOS6, so I need to

  • 0

Sort descriptors with custom blocks are not supported in iOS6, so I need to figure out another way to do this:

A Student entity can belong to one of two sets: confirmedClasses or pendingClasses. I want to fetch Students with the following predicate:

[fetchRequest setPredicate:[NSPredicate predicateWithFormat:@"ANY confirmedClasses.classId== %@
    OR ANY pendingClasses.classId == %@", currentClass.classId, currentClass.classId]];

So a user can be either as a confirmed student in the class or a pending student. What I want is to sort the results so that all confirmed students are listed first, and pending students are listed after all confirmed students.

Any idea how I could accomplish this?

  • 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-13T03:18:16+00:00Added an answer on June 13, 2026 at 3:18 am

    I’d just use two predicates, compound for fetch, and use to filter results:

    NSPredicate *confirmed = [NSPredicate predicateWithFormat:@"ANY confirmedClasses.classId== %@,currentClass.classId];
    
    NSPredicate *pending = [NSPredicate predicateWithFormat:@"ANY pendingClasses.classId== %@,currentClass.classId];
    
    NSArray *predicates = [NSArray arrayWithObjects:confirmed,pending,nil];
    
    [fetchRequest setPredicate:[NSCompoundPredicate orPredicateWithSubpredicates:predicates]];
    
    //Perform fetch into an array called 'results'
    
    NSArray *filteredConfirmed = [results filteredArrayUsingPredicate:confirmed];
    NSArray *filteredPending = [results filteredArrayUsingPredicate:pending];
    
    NSArray *sortedResult = [filteredConfirmed arrayByAddingObjectsFromArray:filteredPending];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to use descriptors in PHP to do the following sort:
I have the following sort descriptors that sort an array of my business objects,
A (sort of - it's not directly to do with C#) related question in
I sort of understand this, at least the function of generators (I've used them
Is there a way to have the sort descriptor(s) be dynamically set for a
Im trying to find a good way to sort people by their Role within
This could well be a real stupid question, but I can't seem to sort
When specifying multiple sort descriptors: NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:lastName, firstName, age, nil];
I am using NSSortDescriptor to sort the custom objects with key bandName , but
I sorted the NSTableColumn using the sort descriptors . I used the following code

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.