• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Enforce Min Count in Core Data To-Many relationship
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Enforce Min Count in Core Data To-Many relationship
      • From: mmalcolm crawford <email@hidden>
  • Prev by Date: setMenuBarVisible: with animation
  • Next by Date: Apple Data Plotting Framework
  • Previous by thread: Re: setMenuBarVisible: with animation
  • Next by thread: Re: Enforce Min Count in Core Data To-Many relationship
  • Index(es):
    • Date
    • Thread