I've a very strange issue. This happens occasionally when I'm trying to remove an object from a to many relationship.
We have 2 objects, a DriverRoute which contains multiple DriverRouteDelivery objects. I try to remove one of the DriverRouteDelivery objects from the DriverRoute, but sometimes the item can't be found in the set even though it's there. I printed the output of lldb.
<DriverRoute: 0x812041a0> (entity: DriverRoute; id: 0x7c0ed070 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRoute/p8> ; data: {
changed = "2015-06-22 15:56:28 +0000";
createdTimestamp = "2015-06-22 15:36:25 +0000";
driver = "0x7f52f080 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Driver/p1>";
id = "4CFA3568-B95E-46D8-A9C7-5EC44BF1ADA8";
returnRoute = "0x7bf15e70 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Route/p23>";
routeDeliveries = (
"0x7bf12930 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRouteDelivery/p24>",
"0x7c663b80 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRouteDelivery/p14>",
"0x7c663f60 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRouteDelivery/p21>"
);
routes = (
"0x7f5df860 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Route/p33>",
"0x7bf131f0 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Route/p22>",
"0x7bf12940 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Route/p29>"
);
startAt = "2015-06-22 15:35:32 +0000";
synced = "2015-06-22 15:56:29 +0000";
})
and
<DriverRouteDelivery: 0x81323d70> (entity: DriverRouteDelivery; id: 0x7bf12930 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRouteDelivery/p24> ; data: {
delivery = "0x7c143b60 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/Delivery/p15>";
route = "0x7c0ed070 <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRoute/p8>";
sortOrder = 1;
})
It's pretty obvious that the Set routeDeliveries contains the object <x-coredata://E8AAE873-94B7-42F4-A39A-3A8D7C567747/DriverRouteDelivery/p24> but if I try e.g. [routeDeliveries containsObject:routeDelivery] it occasionally return NO or if I try to remove the object using the CoreData accessor removeRouteDeliveriesObject: it simply doesn't work, it still contains the object after the call, the printed output above shows it's there.
Both objects are in the same context and the context is used on the correct queue.
Any one any ideas, what might cause this behaviour?