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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:14:06+00:00 2026-05-26T06:14:06+00:00

I have a CoreData model with an object bar which has a to-many relationship

  • 0

I have a CoreData model with an object “bar” which has a to-many relationship “drinks” to the entity “drink”.

The entity drink has only one attribute called “name”.

Now in my app I have a tableView that shows all the bars and has a searchBar included.

In this searchBar I would like to be able to search for the name, location and the possible drinks that are available in a bar.

I have already implemented the name and the location like this:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"
                                       name contains[cd] %@ OR
                       location.name_extern contains[cd] %@ OR 
                       location.name_intern contains[cd] %@", 
                            searchText, searchText, searchText];

So now my question is: How can I search for the name attribute in the NSSet of drinks?

EDIT:

To make it more clear, here are the important data models:

Bar

Attributes: 
name
location
drinks

Location

Attributes:
name_extern
name_intern

Drink:

Attributes:
name

I have a searchText and need to check the following 4 places whether it matches something:

  1. name (of the Bar)
  2. name_extern (of the Location of the Bar)
  3. name_intern (of the Location of the Bar)
  4. name (of ALL the drinks of the Bar)
  • 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-26T06:14:06+00:00Added an answer on May 26, 2026 at 6:14 am

    Something like this should work:

    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"
                                           name contains[cd] %@ OR
                           location.name_extern contains[cd] %@ OR 
                           location.name_intern contains[cd] %@ OR
                       ANY location.drinks.name contains[cd] %@", 
                                searchText, searchText, searchText, searchText];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I have a CoreData entity named, say, 'Book', which has a one-to-one relationship
I have a to-many relationship in my CoreData model without an inverse relationship which
The setup: CoreData Model Product Entity Attribute name Relationship common <---> CommonData CommonData Entity
I have a Core Data model setup like so: Blockbuster Entity To-Many relationship to
In my Core Data managed object model, I have an entity Foo with a
In my core data model I have a Person entity that has a to
I have a CoreData model (managed object) called Item: @interface Item : NSManagedObject {
I have a Core Data model in which a Task entity includes an optional
I have a Core Data model entity NoteObject that has a transformable type arrayOfTags
Everytime I add a new Attribute to my CodeData object model I have to

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.