views:

18

answers:

1

Hello Everyone,

I have a core data database which has (for now) 2 entities Product and CompetingProduct, CompetingProduct relation is set to-many with products.

I create 2 mock Products and 2 mock Competing products and set relation between them .. everything works files.. Saved to database, also NSlog, "po" them.. all is good.

Now.. when i restart the app or i request all objects of competing product type from a different view.. i get Relation fault for the relation between Competing Product and Products (although i added them earlier, and saved)

I know that about the lazy loading of data core but here is not the case because when i try [NSSet allObjects] (also po, nslog - nothing) it returns 0 objects which normally should get objects.

Note: Immediately after i call saveChanges - all things work

Absolutely ANY help will be greatly appreciated and win you my respect and of course a couple of beers

Thanks!

A: 

If I understand the description of the problem correctly, it could be caused by not having a recipocal relationship set from CompetingProduct to Product.

If the relationship is:

Product-->CompetingProduct

...and not:

Product<-->CompetingProduct

... then you will be able to find CompetingProducts starting with a Product but you will be able to find a Product by starting with a CompetingProduct.

If this is not the problem then it sounds like you may have multiple context and are not saving the one the changes are made in.

TechZen
yup. it seems the inverse relation was the problem. Thanks!!
zapacila89
how do i set your answer as the answer?
zapacila89
I believe you click on the tick besides this answer - it'll turn green and that answer is now marked as the approved answer.
John Gallagher