well I set up a little project with coredata and used the XML store .. man that thing is useful.
One thing I was wrong about is that the delete rule on the inverse relationship had to be the same, it doesn't. Don't know why I thought that it had to be. So I found that the forward rule made lots of sense when deleting my Foo instance, deny denied me deleting a Foo, cascade deleted all the Bars in bars, nullify set the foo property in my Bars to nil (and they then happily failed validation as I wanted). All great. The reverse however surprised me. Deny worked the same, it stopped anything getting done, but cascade did exactly what I said I didn't want it to do, the delete of one of the Bars in bars deleted the Foo, which then deleted all the other bars in the relationship. What I actually wanted for the reverse relationship was Nullify, which appeared to have the effect of removing the deleted Bar from bars, and leaving all else alone. On 05-Feb-2010, at 1:35 PM, Roland King wrote: > 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/rols%40rols.org > > This email sent to r...@rols.org _______________________________________________ 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