I'm on my first foray into CoreData, read the docs, much of it makes more sense 
than I expected. 

I'm just setting up my first data model, it's a fairly standard parent object 
(call it Foo) and some kiddies (call them Bar). In the modeller I have set up 
Foo, with a couple of attributes, and Bar, with some too. 

I've added a to-many relationship to Foo calls 'bars' with a destination of 
Bar, then I added the inverse to-one relation to Bar, called foo, so the Foo 
has it's Bars and the Bars know which Foo owns them. I eventually managed to 
get the relationships to be inverses. 

I'm a bit confused about the Delete rule, even after reading the docs a few 
times. I understand that there is one delete rule shared by the pair of 
relationships, as they are inverses of each other. 

If the rule is cascade and I delete a Foo, that means all the Bars in bars will 
be deleted, I get that. What happens if I delete a Bar however? The 
documentation for 'cascade' says "delete the objects at the destination of the 
relationship", but I don't want my Foo to be deleted, I want that Bar to be 
deleted from the bars relationship of the Foo it happens to be related to. Is 
that what would actually happen, or can I just not delete a random Bar like 
that and have it just work, do I need to explicitly remove it from the bars 
relationship of the Foo it's related to, then delete it? 

My feeling from reading the "Manipulating Relationships and Object Graph 
Integrity" is that core data will just do the right thing and in this case 
'cascade' on the inverse of a one-to-many relationship doesn't mean delete the 
object at the other end, it means remove me from the set of objects in that 
relationship, but I can't see that documented anywhere in that way. 

I sure hope that made some sense ... 
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to