Core Data - nil-ing a relationship to a missing object
Core Data - nil-ing a relationship to a missing object
- Subject: Core Data - nil-ing a relationship to a missing object
- From: Steve Steinitz <email@hidden>
- Date: Wed, 26 Sep 2012 13:23:41 +1000
Hi,
If a Core Data to-one relationship is missing its target entity (and so throwing can't-fulfill-fault exceptions), how can I set the relationship to nil?
If I do
object.missingObject = nil;
or
[object setValue: nil forKey: @"missingObject"];
Core Data throws (when it tries to maintain the inverse relationship i.e. remove object from missingObject.objects).
If I do
[object setPrimitiveValue: nil forKey: @"missingObject"];
Core data doesn't seem to know to save the object. At least that's what I think is going on - in any case the relationship is not nil-ed in the store.
At present I have to delete the object (as the doc recommends), but I'd prefer to keep the object and just nil the broken relationship.
I'd prefer to not discuss preventing the situation.
Cheers,
Steve
-----
Avoid loud and aggressive persons for they are vexatious to the spirit - Desiderata
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden