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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:38:18+00:00 2026-05-25T19:38:18+00:00

I have setup few methods to load core data in the background using NSOperationQueue,

  • 0

I have setup few methods to load core data in the background using NSOperationQueue, like the below:

operation = [[NSInvocationOperation alloc] initWithTarget:self                                                      
selector:@selector(selectToLoadDataOne) object:nil];

operation = [[NSInvocationOperation alloc] initWithTarget:self                                                      
selector:@selector(selectToLoadDataTwo) object:nil];

The “selectToLoadDataOne” and “selectToLoadDataTwo” is just standard NSFetchRequest using the template NSManagedContext from app delegate.
Problem is that after loading a few times, it just stop loading altogether and stuck at executeFetchRequest: and without any error.

I know this is related to using of threads with core data, and so I tried to create a new nsmanagedobjectcontext for each call but the result returned are empty nsmanagedobject.

Can someone point me to a good example or doc I can use to solve the loading of core data from 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-05-25T19:38:19+00:00Added an answer on May 25, 2026 at 7:38 pm

    Core Data has very specific rules about running on multiple threads. You must have one NSManagedObjectContext per thread and the thread that a NSManagedObjectContext will be used on must be the thread that creates it.

    You are running into issues because you are breaking that rule.

    Instead of using a NSInvocationOperation:

    1. create a subclass of NSOperation
    2. pass in the NSPersistentStoreCoordinator
    3. create the NSManagedObjectContext in the -main

    Of course that is only going to load them into the NSPersistentStoreCoordinator and you are still going to need to reload them in the main NSManagedObjectContext.

    Why do you need to load data on a background thread? Looking to speed up data loads is usually indicative of a deeper issue in the app.

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

Sidebar

Related Questions

I have a few users setup in the web.config of an asp.net site to
I have setup a property and implement INotifyPropertyChanged like so... public event PropertyChangedEventHandler PropertyChanged;
I've created some MbUnit Test Fixtures that have SetUp methods marked with the SetUp
I have a Java Application which has to load an DLL with a few
I have a Cherokee installation that I'm using to serve a few web applications
I have written a few benchmarks using Caliper . How can I run multiple
I have a setup in the lib directory like so: lib/ copy_process.rb copy_process/ processor.rb
I have setup web dav on windows server 2008. It seems to work fine
At the moment I have setup a custom ok cancel dialog with a drop
I am trying to implement performance testing on ActiveMQ, so have setup a basic

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.