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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:28:20+00:00 2026-05-16T04:28:20+00:00

I have a Group entity which has many Item entities. An Item entity can

  • 0

I have a Group entity which has many Item entities. An Item entity can be in multiple groups. The relevant portion of my model looks like this:

alt text

The Problem

When I call

[fetchedResultsController performFetch:&error]

I get this error in the console

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here' ***

I’m pretty sure the problem is in how I’m setting up the predicate here:

[NSPredicate predicateWithFormat:@"groups == %@", self.group];

But I can’t tell what I’m doing wrong. I’ve read over the NSPredicate documents and I’ve tried this:

[NSPredicate predicateWithFormat:@"ANY groups IN %@", [NSArray arrayWithObject:self.group]];
[NSPredicate predicateWithFormat:@"ANY groups LIKE %@", self.group];
[NSPredicate predicateWithFormat:@"ANY groups == %@", self.group];
[NSPredicate predicateWithFormat:@"ANY groups IN %@", [NSArray arrayWithObject:self.group]];
[NSPredicate predicateWithFormat:@"groups == %@", self.group];

None of which work. This has got to be simple, but I can’t figure it out. I simply want the predicate to filter all the items so as to only return items that are members (through the model relationship) of the group. How do you do this?

I have a NSFetchedResultsController that I am trying to configure to show only the items in a specific group. My code to setup the NSFetchedResultsController looks like this:

// create the fetch request
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];

// configure the entity
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Item" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];

// configure the predicate
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"groups == %@", self.group];
[fetchRequest setPredicate:predicate];

// configure the sort descriptors
NSSortDescriptor *indexSortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"uniqueID" ascending:YES];
NSArray *sortDescriptors = [NSArray arrayWithObject:indexSortDescriptor];
[fetchRequest setSortDescriptors:sortDescriptors];

// create the fetched results controller
NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:managedObjectContext sectionNameKeyPath:nil cacheName:@"ItemsCache"];

// configure the fetched results controller 
aFetchedResultsController.delegate = self;
  • 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-16T04:28:21+00:00Added an answer on May 16, 2026 at 4:28 am

    Without having code to play with it is difficult to be 100% but you should be able to:

    [NSPredicate predicateWithFormat:@"%@ in groups", [self group]];
    

    This is assuming that your fetch is trying to pull back Item entities.

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

Sidebar

Related Questions

I have entities Group and User . the Group entity has Users property which
I have two entities Group and Contact. A contact can belong to many groups,
I have two entities User and Group: @Entity public class User implements Serializable {
I have the following entities in my domain model. A group (an aggregate root)
I have a group model which has_many article model. And I want to use
I have an entity 'Parent' which has a Set of enums private Set<MyEnum> myEnums
I have two tables Group and Customer and of course two entities Group and
I have an 3 object hierarchy which has a root as 'Division' that has
I have an class which has a collection, mapped as a bag in my
I have a 3-leveled hierarchy of entities: Customer-Order-Line, which I would like to retrieve

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.