Enforce Min Count in Core Data To-Many relationship
Enforce Min Count in Core Data To-Many relationship
- Subject: Enforce Min Count in Core Data To-Many relationship
- From: Erik Buck <email@hidden>
- Date: Sun, 11 Jun 2006 06:34:11 -0400
In a trivial Core Data application:
I have an entity called Plan that has a To-Many relationship property
called "pages".
There must always be one or more Pages per Plan, so the in the X-Code
data data model, I have set the Min Count field of the "pages"
relationship property to 1.
Interestingly, setting the Min Count seems to have no effect at all.
I expected that Core Data's built in relationship validation would
enforce the specified Min Count and not for example let the last Page
relationship be deleted. Similarly, I expected that a fetch of a
Plan that has zero pages would produce an error. In fact, it
silently succeeds.
The pages relationship is not set to optional or transient.
The destination is an entity called Page.
There is an inverse relationship: Each Page has one Plan.
pages is a To-Many relationship.
Min Count is 1
Max Count is none
Delete Rule is Cascade
X-Code is Version 2.3
Component versions
Xcode IDE: 744.0
Xcode Core: 747.0
ToolSupport: 733.0
Is there any way for me to get Core Data to enforce the rule that
there should be at least one Page for every Plan ?
Is there some code I need to write to enforce this ?
Have I completely misunderstood the Min Count property of To-Many
relationships ?
Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden