I have a one-to-one unidirectional relationship between a “Booking” object and an “Address” object and a persistent store.
Normally, each booking stays with the same Address, and under normal conditions this works fine.
However, if for some reason the booking address is changed on the server side, I want to update the Booking with a new Address object, and remove the existing Address object from the relationship. This is because I don’t want the original Address object changed – that should stay as it is in the persistent store.
Can anyone tell me broadly whether this is possible in Core Data, and how to go about doing it? I’m currently using the Magical Record Helper library code.
My efforts so far have been to create a new Address object in a transient context, nullify the existing Address object linked to the Booking, and then add the new Address object to the Booking. However, an error is thrown at this last stage. I have also tried making the relationship bidirectional.
What I was doing wrong was using a transient context for the new object, which the object with its relationship being replaced was in the default context. Need to go back to core data school.