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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:54:37+00:00 2026-06-01T01:54:37+00:00

So I have the following code for fetching all of my core data entities

  • 0

So I have the following code for fetching all of my core data entities called Settings

- (NSFetchedResultsController *)fetchedResultsController {

    if (fetchedResultsController_ != nil) {
        return fetchedResultsController_;
    }

    /*
     Set up the fetched results controller.
     */
    // Create the fetch request for the entity.
    NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
    // Edit the entity name as appropriate.
    NSEntityDescription *entity = [NSEntityDescription entityForName:@"Setting" inManagedObjectContext:self.managedObjectContext_];
    [fetchRequest setEntity:entity];

    [fetchRequest setReturnsObjectsAsFaults:NO];
    [fetchRequest setResultType:NSManagedObjectResultType];

    NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"serviceName" ascending:NO];
    NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
    [fetchRequest setSortDescriptors:sortDescriptors];

    // Edit the section name key path and cache name if appropriate.
    // nil for section name key path means "no sections".
    NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext_ sectionNameKeyPath:nil cacheName:nil];
    aFetchedResultsController.delegate = self;
    self.fetchedResultsController_ = aFetchedResultsController;

    [aFetchedResultsController release];
    [fetchRequest release];

    return fetchedResultsController_;
}

I have a property of NSFetchedResultsController *fetchedResultsController and I’ve been using it therough the app via:

[self.fetchedResultsController_ fetchedObjects]

The question is I want to fetch entities with a specific property, i.e: with a predicate:

   NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K == %@", @"settingName", somesettingName];
      [fetchRequest setPredicate:predicate];

The question is should I create a new fetchResultsControllerWithServiceName: (NSString *) serviceName or should I just use the existing method? What is the best practice for this?

  • 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-01T01:54:38+00:00Added an answer on June 1, 2026 at 1:54 am

    It’s surely faster (though I’m not sure how much faster) to modify an existing fetch request controller rather than recreate it each time your predicate needs to be updated. Apple’s documentation states clearly that “you should not use a cache if you are changing the fetch request”, but since you aren’t currently using caching, this is not an issue.

    So, all you need to do to get updated results is update the predicate, call performFetch: on the fetched results controller, and respond to the delegate callbacks you receive.

    You may find it convenient to package up this series of calls into its own method, but you can certainly avoid regenerating the entire controller object when only the predicate is changing.

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

Sidebar

Related Questions

i have following code in which, i am fetching the data from the sqlite
I have following code for inserting data into database using PDO. It inserts data
I have following code: def whatever(url, data=None): req = urllib2.Request(url) res = urllib2.urlopen(req, data)
Been following the Core Data tutorial on Apple's developer site , and all is
I am using following zend code to select all data from a table where
I have the following code for fetching tweets via Twitter4J: List<Status> statuses; Paging paging
I am fetching data from the following database: I have arduino-box that send that
I have the following code to fetch the data from URL, store it in
I have the following code to fetch the data from URL, store it in
EDIT: trying to excute the following code in Winforms. I am fetching the data

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.