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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:47:13+00:00 2026-06-09T13:47:13+00:00

my problem is very strange and I am asking for help. I want to

  • 0

my problem is very strange and I am asking for help. I want to explain to you how my system works. I have two problem with this.

I am making application which have two tables. I am using core data. Tables are Categories and Products, in core data I have established one to many relationship Category can have multiple Products, Product can hove one Categroy.

Here is basic schema

Category {
  site_id
  name
  allProducts ->> Product
}

Product {
  site_id
  name
  category -> Category
}
  • this is simplefied model products and catwegories has more properties

In that application I have updating process, and that process works in backgournd thread. I have created context for that thread and all changes I am storing in that context.

All caluclation I am executing in background thread in

[context performBlock:^{
  // all my operations for updating storing categories and products
}]

This is flow of updateding process

  1. From server get JSON with categories data
  2. From server get JSON with products data
  3. From server get JSON with info which category has which products array((category_site_id > array(product_site_id1, product_site_id2...))

  4. Pass through categories JSON and store category entity, I am getting name and site_id from JSON and create entity and set these properties

  5. Pass through products JSON and create product entity and set name and store_id from properties from JSON

Then main part

  1. Now I need to connect product to categories based on JSON geted in step 3 and here is a problem.

I am going foreach category from JSON and get all products site_id as NSArray, I am using fetch request with predicate and IN criteria to get all products entities from context which have site_id IN array. But I always got zero results. That is strange because I am calling fetch results on context in background thread and I also updated that context in step 3 and 4.

Then I try next thing, before step 6 I [context save:&error] and added sleep about 30 secconds and when after that program run into step 6 all work funtastic my fetch results get products with predicate with IN criteria. That is a my first problem if you understand me, I can not get products by IDs I need to wait about 30 sec to context store to SQLLiteDB it is very strange. Also this is strange because when I want to get category with fetch request by id I can get it without problems (maybe that it is because step 5 takes about one minute).

My next problem is when I wait that 30 sec and then passing trought categories. Based on category site_id I get Category entity from context and also in step 6 I get all products base on product site_ids geted by JSON and fetch request and now I want to add products to category and I call next

[category setAllProducts:results] // results are NSSet of product, category is entity object

NSError *error = nil;
[context save:&error];

and I do that foreach categroy (geted in step 3 from server in JSON format)

when all is done I can not see products in categroies on UI I am also waiting some time to all data be stored in DB but nothing heppenes,

AND THEN WHEN I STOP APPLICATION AND RUN IT AGAIN I CAN SEE PRODUCTS IN CATEGORIES 🙁

very strange problem please help me I do not know where I am a wrong. I can post parts of code, code is not small and I asking for help based on description of process.

Thank you very much

  • 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-09T13:47:14+00:00Added an answer on June 9, 2026 at 1:47 pm

    My understanding is that you are using child contexts. Child contexts are affected by many (many!) bugs you have to deal with.

    Pretty good article about that topic here:

    http://wbyoung.tumblr.com/post/27851725562/core-data-growing-pains

    My advice on that matter is to use a context directly connected to the store coordinator, not a child context. Everything will work fine using such a setup. You can use a private queue context of course.

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

Sidebar

Related Questions

This problem is very strange and I'm hoping someone can help me. For the
I have a very strange problem when I'm testing my application on device. I
I experience a very strange problem and I don't have found any help to
I have a very strange problem with facebook OG. https://fit.upjet.com/en/pages/news/270/ - this is a
I've got a very strange problem recently. I have a code which processes inApp
I have a very strange problem. I'm making a pretty standard ajax-call with jQuery,
I have a very strange problem. I have a login form in Yii which
I got very strange problem. I have one php website which is running in
I have this very strange problem on a big flex app where it would
I have very strange problem. I'm using IIS 7.0 Integrated mode for my application.

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.