Basic app layout using the navigation controller template with core date:
Delegate: persistenceCoordinator, managedObjectModel, managedObjectContext
I have two objects, A & B that share a 1-to-1 relationship/inverse relationship
Using the pattern from the templates the app:
EXCEPTION STEPS 1:
If I simply fill in the A attributes and save everything works fine.
If I then Edit A, I can select Add B and an add B view is pushed on (and passed the A entity)
EXCEPTION STEPS 2:
If I fill in the A attributes AND the B attributes in the initial "add"
I've tried saving A first, adding a separate context for B etc etc. I'm confused to say the least. Any help would be greatly appreciated.
Cheers, Ryan
It sounds like you have two or more managed object context when you just need one.
I don't know why you would have a method called addManagedObjectContext
in the RootViewController or what it would do. In all but the most complex designs, you have only one context at a time and they don't overlap. The context/s should be held by the app delegate or a dedicated model object. You would never create a new context every time you open a particular view.
You can have different context all writing to the same persistent store so I think this is why you are seeing the data in the store. However, you can't maintain graph integrity across context if you put one object in a relationship in one context and the other side of the relationship in another context. I believe this is what is producing your error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With