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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:10:41+00:00 2026-05-25T16:10:41+00:00

I have a CoreData application with dynamic data that is updated once a day

  • 0

I have a CoreData application with dynamic data that is updated once a day via a server.

The update is handled in a seperate class and in the AppDelegate I write:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.updater = [[Updater alloc] init];
    ...
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    [updater checkForUpdatesInContext:[self managedObjectContext]];
}

The checkForUpdatesInContext checks whether a day has passed or not and then does the updating process.

Now this way of course it would run on the main thread, and if an update is going on, the app would “freeze” until the update is done, which could take a while, since new objects are created and there’s also images involved. So my idea was to run this on a background thread or on a second thread or whatever Objective-C offers.

My question: What would be the most efficient way to get checkForUpdatesInContext off the main thread and how to go about it? The apple docs are (as usual) somewhat confusing.

  • 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-25T16:10:43+00:00Added an answer on May 25, 2026 at 4:10 pm

    Getting the update operation to happen in a background thread isn’t that tricky e.g.

    [self performSelectorInBackground:@selector(updateWithData:) withObject:data];
    
    ...
    
    - (void)updateWithData:(NSData *)data {
        // I am now in a background thread
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    

    or if you are looking for the ability to cancel the background thread, read up on NSOperation and NSOperationQueue.

    Your problem is going to be dealing with multithreading and CoreData 🙂 You need to read this guide. Basically, you need to make sure that your background thread doesn’t use the same NSManagedContext (it must create a new one from the same NSPersistentStore) and doesn’t pass NSManagedObjects between threads (i.e. only pass object IDs back to the UI thread, not the objects themselves).

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

Sidebar

Related Questions

I have an application that uses CoreData. I previously had a class named Marker
I have an application that uses coredata. The Download of data happens in a
I have a CoreData-based application that retrieves data about past events from an SQLite
I have a Core Data based mac application that is working perfectly well until
I have an application that uses Core Data that has a relationship that I
I have a UITableView that fetches data from CoreData using FetchedResultsController and it registers
I have a classic CoreData application, displaying it's data in NSTableView with Binding (all
I'm using core data on an iPhone application. I have multiple persisntent stores that
I have a core data application which uses a navigation controller to drill down
I have an application using Core Data and bindings. I want to have an

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.