views:

176

answers:

1

I have a core data model which includes an entity with a to-many relationship. I have set the relationship to non-optional and set the 'min count' to one. However, I can't work out a way of acting on this rule once it has been breached. Ideally I'd just like the entity deleted... but I can't figure out a way to do this automatically, or work out where I might be notified of this event.

+1  A: 

You should be able to use KVO for this. Register for notifications on the relationship property within the entity, and have it delete itself if the count falls below the minimum number.

Marc Charbonneau