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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:44:09+00:00 2026-05-31T17:44:09+00:00

I am developing an app where a synch with the backend should not block

  • 0

I am developing an app where a synch with the backend should not block the UI.
Therefore I do use many MOCs and those MOCs operating the download and import via its performBlock method (Which will automatically be done in a background thread).

My background MOCs are created as a child of the main moc:

context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType];
[context setParentContext:aConfiguration.context];
coordinator = aConfiguration.coordinator;
model = aConfiguration.model;
store = aConfiguration.store;
errorHandler = aConfiguration.errorHandler;

So most works fine so far, but there is a significant problem.
I downlod text and image data. So in the UI I want to display the text first and then, for each downloaded image, fading in this downloaded image.
Usually no problem, the downloader completes an image download and calls its delegate (a Service) ala

downloder:(id<Downloader) aDownloader didFinishDownloadImageItem: (id) aObjectWithImage

whereas aObjectWithImage is my model object with the new downloaded image.

The delegate will put the object in a notification and post this notification

NSDictionary *userInfo = [[NSDictionary alloc] initWithObjects:[NSArray arrayWithObject:aObjectWithImage]
                                                       forKeys:[NSArray arrayWithObject:EntityWithImageDownloadedNotificationInfoKeyEntity]];    
[[NSNotificationCenter defaultCenter] EntityWithImageDownloadedNotification object:self userInfo:userInfo];

And here starts the problem. Lets say an UIViewController of mine will observe those notifications. After receiving one he would search through his array of objects to display for the one in the info dictionary to change the image.

You see the problem? He will never ever find this object! Due to the fact, that originally this object was created in a background thread and therefore another MOC, the object references in the UIViewController’s array of object (main MOC) is always different to the one posted by the notification (background MOC).

I know how to solve this problem, the delegate posting the notification could search for the object on its MOC (which is the main one) but I kind of don’t like this idea. It’s not wrong I think, because the Service also created the background thread, so it knows that all objects received in the delegate methods are within the MOC of the background thread.

Some suggestions how I could handle this issue better?
I really would appreciate any of your ideas!

  • 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-31T17:44:10+00:00Added an answer on May 31, 2026 at 5:44 pm

    What concurrency type are you using? I’m guessing NSPrivateQueueConcurrencyType for your background MOC, from what you’re saying about using performBlock: to wrap your queries. Is your main thread MOC using NSMainQueueConcurrencyType?

    I think you want to do something like what is described in this answer. Inside your background MOC’s block, tell your main MOC to perform a block, and pass the managed object across by means of its object ID.

    You might ask, how does the new managed object exist in the main thread’s MOC? Easy: you make the background MOC a child of the main thread MOC. When you call save on the background MOC, it pushes its new objects into its parent MOC, which is your main one. Do that just before you do the passing the object ID across, and your object will be there.

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

Sidebar

Related Questions

I'm considering developing an app for Google App Engine, which should not get too
When developing an app that will listen on a TCP/IP port, how should one
I'm developing an app where I use performSelectorInBackground to do some sync task in
I am developing app for Android. And as some of members suggested to use
i am developing app in blackberry version 5.0, and i had import all library
i am developing app in blackberry version 5.0, and i had import all library
Should I be developing my app for 4.2?
I am developing app in VB.NET that should have HTML requests and getting responses
Developing an app that people pay a monthly subscription to use. They can pay
Greeting, I'm a C# programmer guy. I'm planning to start developing app for iphone

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.