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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:32:10+00:00 2026-05-27T15:32:10+00:00

I have an NSFetchedResultsController on the main thread. Also from the main thread, I

  • 0

I have an NSFetchedResultsController on the main thread. Also from the main thread, I asynchronously send out a network request for JSON. When that JSON string returns, I start an NSOperation that inits a new (background) NSManagedObjectContext, parses the JSON string, creates/updates NSManagedObject‘s, and saves them in the context. The background context has the same persistentStore as the main context. With this, I have 2 questions:

  1. I thought that any saves to the persistent store from any context (on any thread) would notify the main NSFetchedResultsController that there are changes, but so far it doesn’t pick up any changes. Is there something I should do to notify the main thread’s NSFetchedResultsController that there were external save‘s so that the tableView updates accordingly?

  2. So, on the main thread, I subscribe to NSManagedObjectContextWillSaveNotification and correctly see when all contexts (including those existing entirely on a separate thread) perform a save operation. The apple docs say that the notification.userInfo should have a dictionary of 3 arrays, one array for each of the “updated, deleted, and inserted” model objects on the background thread. However, the userInfo is always nil for me. Any ideas what I’m doing wrong?

Subscribing to the NSManagedObjectContextWillSaveNotification in AppDelegate:

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(managedObjectContextDidSave:)
                                             name:NSManagedObjectContextWillSaveNotification 
                                           object:nil];

And the method for when contexts are saved in AppDelegate:

- (void)managedObjectContextDidSave:(NSNotification *)notification {
    DLog(@"notification: %@", notification); //not nil
    DLog(@"notification user info: %@", notification.userInfo); // always nil... why??

    NSManagedObjectContext *theContext = notification.object;
    if(theContext != context) {
        DLog(@"---- SAVED ON ANOTHER CONTEXT");

        // should I notify NSFetchedResultsController that there were context saves on background threads?
        // how can I merge contexts if userInfo is nil?
    }
}

I’d also like to know the best practices in dealing with multiple threads (with separate NSManagedObjectContexts) and Core Data.

  • 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-27T15:32:10+00:00Added an answer on May 27, 2026 at 3:32 pm

    You observe the wrong notification: the name of the notification you need to observe is NSManagedObjectContextDidSaveNotification (not NSManagedObjectContextWillSaveNotification).

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

Sidebar

Related Questions

I have a UITableView that updates from a NSFetchedResultsController . The UITableView has alternating
I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext . These objects
I have a table view that is managed by an NSFetchedResultsController. I am having
I have a UITableViewController fed by an NSFetchedResultsController. From it, the user can call
I have to perform a fetch via NSFetchedResultsController on a background thread. My current
I have implemented a UITableView with the NSFetchedResultsController to load data from an sqllite
Setup: I have several UITableViewControllers (tvc) that all instantiate a separate NSFetchedResultsController (frc). All
I have a NSFetchedResultsController which is fetching objects from a NSManagedObjectContext . I'm using
I have setup a UITableView using a NSFetchedResultsController that displays a number of prototype
I have a tableview using NSFetchedResultsController to load data from the Core Data store,

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.