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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:20:56+00:00 2026-06-10T15:20:56+00:00

I have a mutable array of managed objects that I get from Core Data

  • 0

I have a mutable array of managed objects that I get from Core Data – let’s call them ObjectA. ObjectA has a many-to-many relationship with ObjectB, such that each ObjectA has an NSSet of ObjectBs. ObjectB has a one-to-many relationship with ObjectC, i.e. each ObjectB has one ObjectC.

Now that that’s clear (hopefully), here is what I want to do: I want to filter my array of ObjectAs based on the name of a given ObjectC. In other words, I start with an array of all my ObjectAs in Core Data, and I want to end up with only the ObjectAs that own an ObjectB whose ObjectC is named “Potatoes” (for example). I hope that makes sense…here’s a dummy situation: a person (ObjectA) can have many songs (ObjectB), and songs can be owned by many people. I have an array of every person, but I want only the people who have songs that belong to a specific album (objectC). Hopefully that helps to clarify the situation.

So, does anyone have any advice on how to best filter through my ObjectAs based on a given ObjectC? I could certainly brute force it with a bunch of loops and ifs, but I’m wondering if there’s a more efficient way to do it in fewer steps with something like NSPredicate (which I’ve used before, but not in a multi-layered situation like this).

Any suggestions would be appreciated!

EDIT

here is a diagram of my model:

model diagram

  • 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-10T15:20:58+00:00Added an answer on June 10, 2026 at 3:20 pm

    If I understand your problem correctly, the following fetch request should work:

    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"ObjectA"];
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY objectBs.objectC.name = %@", @"Potato"];
    request.predicate = predicate;
    
    NSError *error;
    NSArray *result = [context executeFetchRequest:request error:&error];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a mutable array that has about 100 objects in it and each
I have a UITableView that was created from data coming from a mutable array.
I have a mutable array that is retained and storing several objects. At some
I have a mutable array that has been retained. This array contain dictionaries with
I have a mutable array of custom objects. I want to filter that array
I have used a number of grouped tables tied to core data managed objects,
I have an mutable array of say 20 objects. And it has values like
I've been having a really weird problem. I have a mutable array that is
I have a one-time need to create a file from an iOS mutable array.
I have an non-mutable array that only needs to have numbers. How would I

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.