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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:20:09+00:00 2026-06-10T03:20:09+00:00

I have an app with two managed object contexts setup like this: Parent Context:

  • 0

I have an app with two managed object contexts setup like this:

  • Parent Context: NSPrivateQueueConcurrencyType, linked to the persistent store.
  • Main Context: NSMainQueueConcurrencyType, child of Parent Context.

When insert a new managed object to the main context, I save the main context and then the parent context like this:

[context performBlockAndWait:^{
    NSError * error = nil;
    if (![context save: &error]) {
        NSLog(@"Core Data save error %@, %@", error, [error userInfo]);
    }
}];

[parentContext performBlock:^{
    NSError *error = nil;
    BOOL result = [parentContext save: &error];
    if ( ! result ) {
        NSLog( @"Core Data save error in parent context %@, %@", error, [error userInfo] );
    }
}];

My understanding is that when the manage object is first created, it has a temporary objectID. Then the main context is saved and this object, with its temporary ID, gets to the parent context. Then the parent context is saved. When this last context is saved, the temporary objectID in the parent context gets transformed into a permanent objectID.

So:

  • Does the permanent object ID ever get propagated automatically back
    to the main (child) context?
  • When I force to get the object permanent ID with
    [NSManagedObjectContext obtainPermanentIDsForObjects:error:], then background the app, reactivate it, reload, get the object using main context’s objectWithID:, and access a property, I get

    “CoreData could not fulfill a fault for …”.

What is wrong with this approach?

  • 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-10T03:20:12+00:00Added an answer on June 10, 2026 at 3:20 am

    It is a known bug, hopefully fixed soon, but in general, obtaining a permanent ID is sufficient, provided you do so before you save the data in the first child, and you only include the inserted objects:

    [moc obtainPermanentIDsForObjects:moc.insertedObjects.allObjects error:&error]
    

    In some complex cases, it is better to get a permanent ID as soon as you create the instance, especially if you have complex relationships.

    How and when are you calling obtainPermanentIDsForObjects?

    I do not follow the part about the app crashing. Maybe a better explanation would help.

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

Sidebar

Related Questions

I am using two managed object contexts in my iOS app. The first context
I have a single un-managed C++ console-app solution (.sln) with two projects (.vcproj) both
I have two app icons built-in (free and premium), is it possible to replace
I have an app with two view controllers. ViewControllerA is a blank view with
Is it possible to have two app.config files where one app.config serves as a
I have an app with an UINavigationController and two tableviews. When I switch between
I have a very basic app with two ignition-remoteimageviews (RIV) in them. The app
I have an App that I want to have two version in the App
I have an app that so far consists of two Activities: The Main Menu
I have an app that has a centre view with two views off 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.