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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:21:32+00:00 2026-06-08T18:21:32+00:00

In iOS5, I have a NSManagedObjectContext which I create with a NSPrivateQueueConcurrencyType, like so:

  • 0

In iOS5, I have a NSManagedObjectContext which I create with a NSPrivateQueueConcurrencyType, like so:

self.moc = [[[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType] autorelease];
moc.parentContext = rootContext;

This executes on the main thread, but if I understand the doc correctly that shouldn’t matter, since the MOC gets its own queue, right?

Now, at some point I perform a fetch request, like so:

[self.moc performBlockAndWait:^() { // (1)
    NSError* err = nil;

    result = [self.moc executeFetchRequest:request error:&err];

    NSLog(@"%@ %@", [NSThread currentThread], [NSThread isMainThread]?@"MAIN":@"");
}];

The invocation (1) is also called on the main thread. But I expect the fetch request inside the block to execute on the private MOC thread. Correct so far?

However, if I check the current thread inside the block, it actually is the main thread! The NSLog prints:

<NSThread: 0x6b10780>{name = (null), num = 1} MAIN

Checking the thread dump confirms this.

The fetch should NOT be executed on the main thread, because this does occasionally result in a deadlock with some other running code. So what am I doing wrong here?

  • 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-08T18:21:33+00:00Added an answer on June 8, 2026 at 6:21 pm

    Ok, I’m still not entirely sure about the mechanics here, i.e. how something posted on the context-private queue ends up on the main thread. I suspect it has to do with the performBlockAndWait, which executes the block synchronously. I have rewritten stuff so everything is now done asynchronously, and the block is now executed on its private thread.

    Thanks for all suggestions.

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

Sidebar

Related Questions

This is on iOS5 w/ a storyboard. I'd like to have a UINavigationController on
In my iOS5 app for iPhone I have something like this AppDelegate ivar ViewController1
I have a UITableView in an iOS5.1 app where I set self.tableView.allowsMultipleSelection=YES; The Apple
I am working on ios5 and have used NSURLConnectionDataDelegate in my application which really
I have this problem with a tableview in iOS5 that is giving me errors,
I am just learning objective-C, and have a book with code like this: NSArray
i have an app always working till i have installed ios5 on device. this
Possible Duplicate: ios5 new Notification Center issue Many apps have established a paradigm like
I have developed an iPhone application which should support iOS4 and iOS5 based iPhone/iPad.
I'd like to develop for iOS5 and have a storyboard... I've just created UIView

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.