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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:10:13+00:00 2026-06-09T18:10:13+00:00

I am not getting NSManagedObjectContextDidSaveNotification notifications from the NSManagedObjectContext I give to Simperium. Basically

  • 0

I am not getting NSManagedObjectContextDidSaveNotification notifications from the NSManagedObjectContext I give to Simperium.

Basically what I like to do is inform my application when an update of the database has happened due to an update by simperium.

Therefore I am using 2 NSManagedObjectContexts, one for my application and the other one for Simperium. Once my application saves its context, the changes are merged to the simperium context in the NSManagedObjectContextDidSaveNotification notification via mergeChangesFromContextDidSaveNotification:.

The problem however is that whenever there is an update to the Simperium NSManagedObjectContext, I don’t get a NSManagedObjectContextDidSaveNotification and thus I can’t merge the changes from remote to my application context. I checked that it actually save the data to the persistent store.

Some code:

- (void) setSyncingEnabled:(BOOL)syncingEnabled
{
    if (syncingEnabled && !self.simperium)
    {
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(syncingObjectContextDidSaveNotification:)
                                                     name:NSManagedObjectContextDidSaveNotification
                                                   object:self.syncingObjectContext];

        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(objectContextDidSaveNotification:)
                                                     name:NSManagedObjectContextDidSaveNotification
                                                   object:self.objectContext];

        self.simperium = [[Simperium alloc] initWithRootViewController:App.delegate.window.rootViewController];
        self.simperium.authenticationOptional = YES;
        [self.simperium addDelegate:self];

        [self.simperium startWithAppID:kSimperiumAppId
                                APIKey:kSimperiumAPIKey
                                 model:self.objectModel
                               context:self.syncingObjectContext
                           coordinator:self.storeCoordinator];
    }
    else if (self.simperium) {
        self.simperium = nil;

        [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:self.syncingObjectContext];
        [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:self.objectContext];
    }
}


- (void) objectContextDidSaveNotification:(NSNotification*)notification
{
    if (self.simperium) {
        [self.syncingObjectContext mergeChangesFromContextDidSaveNotification:notification];
    }
}

- (void) syncingObjectContextDidSaveNotification:(NSNotification*)notification
{
    [self.objectContext mergeChangesFromContextDidSaveNotification:notification];

    /* Inform Application */
    [[NSNotificationCenter defaultCenter] postNotificationName:DatabaseDidUpdateExternallyNotification object:self];
}
  • 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-09T18:10:15+00:00Added an answer on June 9, 2026 at 6:10 pm

    Since your goal is to inform your app when an update has happened via Simperium, there are better options than using a separate context (which Simperium does internally anyway):

    1) You can use an NSFetchedResultsController which will get called as objects are inserted, changed, and removed.

    2) You can use SimperiumDelegate to react to specific changes. This works a bit differently in the release that is currently being tested in the “iosupdate” branch on GitHub. The SimperiumDelegate protocol will be replaced by SPBucketDelegate to give you more control over the notifications you care about.

    If for some reason you really need to use a second context, please get in touch so we can talk about your use case a little more.

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

Sidebar

Related Questions

Not sure why but I am not getting anything back from the json call.
I'm not getting the partial template specialization. My class looks like this: template<typename tVector,
update: After not getting anywhere with this, I noticed that when I pulled the
Update: since I'm not getting any answers, I've rewritten the entire post using a
Since I am not getting anywhere with my previous question , I would like
I not getting the desired effect from a script. I want the password to
My object is not getting released from memory so I override retain method and
I am not getting results back from grep when I call it with a
I am not getting response while fetching result from my code using AJAX. while
I am not getting any error in my application but when I run it

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.