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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T19:00:40+00:00 2026-06-09T19:00:40+00:00

I want a simple predicate that returns me all the groups which have mode

  • 0

I want a simple predicate that returns me all the groups which have mode = 0 and the mode of the enrollments in the group = 0

To be precise i need a predicate to access the nested object properties.
Somehow a predicate like:

[NSPredicate predicateWithFormat:@"mode = 0 AND enrollments.Enrollment.mode = 0"]

the above predicate is wrong and obviously doesn’t work.

EDITED:

I have given a go to the following predicate too but been unsuccessful.

[NSPredicate predicateWithFormat:@"mode = 0 AND ALL ( SUBQUERY(enrollments,$varEnrollment,$varEnrollment.mode = 0))"]

I need result which contains all groups that are active (group.mode = 0) AND with all enrollee’s that are active (enrolles.mode = 0)
but for me this predicate doesn’t work.

  • 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-09T19:00:42+00:00Added an answer on June 9, 2026 at 7:00 pm

    From your question and the comments I guess that you want

    [NSPredicate predicateWithFormat:@"mode = 0 AND (ALL enrollments.mode = 0)"]
    

    UPDATE

    It seems that the ALL aggregate does not work. It throws

    'NSInvalidArgumentException', reason: 'Unsupported predicate (null)'
    

    as @yunas noticed. This has also been noticed previously, e.g.

    • Core Data, NSPredicate and to-many key
    • Crash using Aggregate Operation: "ALL" in a Core Data iOS Application

    On the other hand, the ANY aggregate works just fine. So as a WORKAROUND, one can replace ALL with an equivalent ANY expression:

    [NSPredicate predicateWithFormat:@"mode = 0 AND NOT(ANY enrollments.mode != 0)"];
    

    And this actually works (I have tested it)!

    UPDATE 2

    During the discussion it has become clear that yunas wants to display a table with one row for each group with mode=0, and within the table row display all enrollments of that group with mode=0.

    First solution (probably the better one): Find all admissible groups first with the method given above. For each row (in cellForRowAtIndexPath:) filter the enrollments for that group and draw the cell.

    Second solution: Fetch all enrollments and sort them by group. This requires only one fetch request, but the result is not so suitable as table view data source. The fetch request would look like this:

    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Enrollment"];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"mode = 0 AND group.mode = 0"];
    request.predicate = predicate;
    NSSortDescriptor *sort1 = [NSSortDescriptor sortDescriptorWithKey:@"group.name" ascending:YES];
    NSSortDescriptor *sort2 = [NSSortDescriptor sortDescriptorWithKey:@"share" ascending:YES];
    request.sortDescriptors = [NSArray arrayWithObjects:sort1, sort2, nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge table and I want simple sorting. It could be so
I want a simple sign in app in which a user logins successfully if
I understand that Silverlight 3.0 has binding but just want a simple example on
I have a Group entity which has many Item entities. An Item entity can
We have a project using LINQ to SQL, for which I need to rewrite
I have a long, lazy sequence that I want to reduce and test lazily.
I have a simple base entity type called EntityBase that implements IEquatable<EntityBase>. I've used
I have an array of objects that I'd like to filter using a predicate,
I have a collection of elements that I need to operate over, calling member
I want a simple TextView to behave the way simple_list_item_1 in a ListView does.

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.