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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:04:14+00:00 2026-05-26T14:04:14+00:00

Following the iOS5 release notes and WWDC2011 presentation examples, I setup a root managed

  • 0

Following the iOS5 release notes and WWDC2011 presentation examples, I setup a root managed object context as type NSPrivateQueueConcurrencyType. I have a child context which is of type NSMainQueueConcurrencyType (referred to as the default context).

When I save the child context, then save the root context using the block API: performBlockAndWait:, I expect the operation to by synchronous.

That is, right after this block executes, I should be able to get non-temporary ObjectID‘s for all the objects just inserted all the way to the data store.

However, I instead, get temporary object IDs! It’s as if the performBlockAndWait: degenerates to performBlock: and runs async. But why?

Is this a bug, or am I missing some key assumption?

Here’s some relevant code:

// Setup of the root MOC:
__rootContext = [[NSManagedObjectContext alloc] 
    initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[__rootContext setPersistentStoreCoordinator:[self coordinator]];

// Setup of the child MOC; I use it as the "default" context:
__defaultContext = [[NSManagedObjectContext alloc] 
    initWithConcurrencyType:NSMainQueueConcurrencyType];
[__defaultContext setParentContext:__rootContext];

// Here's the essence of the save operation:
[__defaultContext save:&error]

// Setup a block I can invoke that does the save:
void (^rootContextSaveOperation)(void) = ^{
    NSError *rootContextError = nil;
    BOOL wasRootContextSaveSuccessful = [rootContext save:&rootContextError];
    if (!wasRootContextSaveSuccessful) { 
        NSLog(@"RPDataStore: Error saving root context."); }
    };

// Call perform block and wait with the operation:
[__rootContext performBlockAndWait:rootContextSaveOperation];

// Now when I inspect one of the objects just saved, I have this check in my unit test:
BOOL isTempID = [[user objectID] isTemporaryID];

The problem is, for the “user” object part of the MOC hierarchy just saved from it’s leaf MOC to the root, the “isTempID” flag unfortunately, reveals “YES”.

My expectation was that I could perform a save synchronously to get a permanent Object ID I could use in other contexts.

Are my conceptual expectations of performBlockAndWait: incorrect?

If so, how do I save synchronously with this MOC queue configuration and still get non-temporary ObjectIDs right away?

  • 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-26T14:04:14+00:00Added an answer on May 26, 2026 at 2:04 pm

    For whom it might be helpful, my workaround was to build a fetch predicte for the managed object that would uniquely retrieve it.

    I execute this fetch against the root managed object context, and then, I reliably get a non-temporary Object ID for managed objects that I did previously save. In my case, I already had managed objects that report back what set of keys can be used in a search, that would uniquely identify them.

    The other option, is to obtain permanent Object IDs for all objects in the context before that initial save of the child context. You can then use NSManagedObjectContext’s refreshObject:mergeChanges: to refresh the current reference of a particular object in scope. Now it will reflect changes just saved in a child context.

    Obtain permanent object IDs using NSManagedObjectContext’s method obtainPermanentIDsForObjects:error:

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

Sidebar

Related Questions

following setup, i have several generic functions, and i need to choose the type
The following code does not work with iOS5: - (void)loadURL { NSString *path =
I have an app in the process of upgrading to the iOS5 SDK and
I'm trying to integrate the Facebook SDK into an iOS5 project I'm building. Following
I get the following warning when I run my app in iOS5 CoreData: warning:
I have the following simple code to display a pdf in a webview. I've
I have the following code to retrieve file paths on my iOS Apps: static
Following code works in debug mode, but in release mode there are only blank
Following up on this question, I have the following 2 options: $(tr td).slice(3, 6);
following is my code, i don't know why DateTime can not change to Object

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.