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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:27:58+00:00 2026-06-13T08:27:58+00:00

I have two entities in core data with one to many relationship between them

  • 0

I have two entities in core data with one to many relationship between them (Dream has one to many relationship with symbols). I have also provided search functionality by using predicate and the appropriate searchFetchedResultsController which is called when search is happening.
Now I want to implement search scope functionality using search bar scope buttons. How can I change my predicate so that it filters the content based on symbols rather than filtering on dream which is working fine. Do I need to create another fetchedResultsController or I should modify the predicate in this searchFetchedResultsController to get the desired results???

    - (NSFetchedResultsController *)newFetchedResultsControllerWithSearch:(NSString *)searchString {
NSFetchRequest *fetchRequest = [[[NSFetchRequest alloc] init] autorelease];

// Edit the entity name as appropriate.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Dream" 
                                          inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];

// Set the batch size to a suitable number.
[fetchRequest setFetchBatchSize:20];

// Edit the sort key as appropriate.
NSSortDescriptor *sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"dateTimeStamp" ascending:NO] autorelease];
NSArray *sortDescriptors = [NSArray arrayWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];

// Configure predicate
NSPredicate *filterPredicate = nil;

if (searchString.length) {
    filterPredicate = [NSPredicate predicateWithFormat:@"note CONTAINS[cd] %@", searchString];
}

[fetchRequest setPredicate:filterPredicate];

NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest 
                                                                                            managedObjectContext:self.managedObjectContext 
                                                                                              sectionNameKeyPath:nil 
                                                                                                       cacheName:nil];
aFetchedResultsController.delegate = self;

NSError *error = nil;

if (![aFetchedResultsController performFetch:&error]) {
    /*
     Replace this implementation with code to handle the error appropriately.

     abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development. If it is not possible to recover from the error, display an alert panel that instructs the user to quit the application by pressing the Home button.
     */
    NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
    abort();
}

return aFetchedResultsController;
}  
  • 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-13T08:27:59+00:00Added an answer on June 13, 2026 at 8:27 am

    No need for a separate fetched results controller.

    The predicate could be something like this:

    fetchRequest.predicate = [NSPredicate predicateWithFormat:
       @"ANY symbols.name CONTAINS[cd] %@", searchString];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two Core Data entities: Parent and Child . Parent has to-many relationship
I have core data model with two entities that have a many-to-many relationship with
In my Core Data model I have two entities: List and Patient. List has
I have two entities: Patient and Job. Patient has a to-many relationship to Job
I have created a core data model that has two entities which have a
In my project, I have two Core Data entities. One is the grouping (can
I have a core data model that has two entities, Bid and Result. I
I have a Core Data model with two entities: A and B. A has
I have two core data entities. Lets call them AAA and BBB . BBB
I have two entities with many-to-many relationship defined on them. <set name=TreasuryCodes table=ServiceProviderAccountTreasuryCode lazy=true

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.