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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:21:58+00:00 2026-06-04T01:21:58+00:00

I have researched a ton of posts regarding Core Data on background threads, and

  • 0

I have researched a ton of posts regarding Core Data on background threads, and I feel like I understand (on paper) what needs to be going on. I guess we’ll see. I am working on migrating an existing OS X app to Core Data, and am having issues making new instances of my NSManagedObject on an async thread.

Here is a sample of the code I am running right after I have moved onto a background thread:

NSLog(@"JSON 1");
NSManagedObjectContext * context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator:[[NSApp delegate] persistentStoreCoordinator]];
asset = (MTAssetInfo*)[NSEntityDescription insertNewObjectForEntityForName:@"Info" inManagedObjectContext:context];
NSLog(@"JSON 2");

The result is that the first log message (@"JSON 1") gets called 31 times, and the second one (@"JSON 2") is never called. The object isn’t being made and returned correctly.

The model for this Info entity is quite complex with a few transformable attributes that may or may not be setup correctly. The weird thing is that similar code run on the main thread and the main MOC works great. No issues.

EDIT – Some more context

The async call originates from here:

for (NSNumber *sectionID in sectionsToShow) {
    dispatch_group_async(group, queue, ^{
        MTAssetInfo *asset = [self assetWithRefID:[sectionID unsignedIntegerValue]];
        if (asset != nil) {
            [sectionsLock lock];
            [sectionsTemp addObject:asset];
            [sectionsLock unlock];
        }
    });
}

The assetWithRefID method never returns with an object because of the other code snippet. It never successfully pulls an NSManagedObject out of the context on the background thread.

  • 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-04T01:22:00+00:00Added an answer on June 4, 2026 at 1:22 am

    You are going to have to provide more information to get real help, but I bet your problem is an error happening in the NSManagedDocument background thread.

    I’d register a NSNotificationCenter for ALL messages (name:nil object:nil) and just print them out. I bet you see a status change or error message in there that is failing.

    You might want to try a @try/@catch block around it just to see if exceptions are being thrown.

    Maybe it will give you more to go on.

    One other suggestion… Swizzling isn’t necessarily the right tool for production stuff, but it’s almost unbeatable for debugging. I have method-swizled several entire classes, so that it sends a detailed NSNotification before/after each invocation.

    It has saved me tons of time, and helped me track down some wicked bugs. Now, when something is going on in CoreData, I take out my set of classes, link them in, and see all the detail I want.

    I know that does not exactly answer you question, but hopefully it will put you on the track so you can provide some more information and get it all fixed.

    If that’s too much for you, create a subclass and instantiate that, with a similar method for calling super. You can get a real idea of the entire flow pretty easily.

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

Sidebar

Related Questions

I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
Okay I'm looking for some assistance I have researched and read posts that pertain
I have situation where my Java class needs to create a ton of certain
I have researched this for about 3 days non-stop and I'm starting to feel
I have researched SASS and Blueprint seperately, and think I understand how they work,
I have researched this topic for months now with no success. Many posts say
I have researched this for a few hours and I am kind of frustrated.
I have researched enough on this topic sans any luck :-( My requirement is
I have researched and researched and I am trying to use jquery to refresh
I have researched a lot about creating my own app for android with a

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.