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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:22:36+00:00 2026-06-12T06:22:36+00:00

I have a core data object A. Object A contains an array of objects

  • 0

I have a core data object A.

Object A contains an array of objects B – like A.bObjects.
Object B contains an array of objects C – like B.cObjects.

How can I get all objects B from object A where B.cObjects is nil?

I can work around this like:

NSMutableArray *array = [[NSMutableArray alloc] init];
for(B *b in A.bObjects)
{
    if([b.cObjects count] == 0)
        [array addObject:b];
}

But i think it will take a lot of resources if I would have a lot of objects B. And I do not like my workaround.:)

Any ideas?

  • 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-12T06:22:38+00:00Added an answer on June 12, 2026 at 6:22 am

    I believe you could use, if you just want all the Bs from a particular A that have empty cObjects.

    NSPredicate* predicate = [NSPredicate predicateWithString:@"cObjects.@count == 0"];
    NSArray* emptyCObjects = [A.bObjects filteredArrayUsingPredicate:predicate];
    

    If you want all the Bs from all of the As that have empty cObjects, combine that with a NSFetchRequest.

    Not a 100% sure which would be more effective, but if I were to hazard a guess, I would say use predicates and KVC as I believe Apple has made some optimisations under the hood. Also its fewer lines of code whi

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

Sidebar

Related Questions

I have a Core Data object that contains an NSSet of other objects (e.g.
I have a core data 'ShoppingList' which contains 'Item' objects. I store a display
I have objects with location data stored in Core Data, I would like to
I have a core data recipe object that contains an ordered list of ingredient
I have something like this on my core data class to fetch all data
I have a core data object and a REST web interface that use different
I have a core data UITableView, the core data managed object has 4 properties
I have a list of core data objects each has a longitude and latitude
I have a core data context with objects that have a date stored in
i have a tableview application loaded with core data feltching objects and i wanna

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.