views:

15

answers:

1

In core data, in the xcdatamodel file, if i want to specify a parent object, but for one of the children of the parent object, i want a property to be optional, and for the other, i don't want to check optional, is there a way to do that? or should i just take the property out of the parent and put it in the children so that I can make one optional and the other not optional?

+1  A: 

I think the best way to do is to make the property optional, and changing this behavior in some of the subclasses by implementing your own validation mechanism (documentation available in the Core Data docs, validation is part of the API)

Then by default the property is optional, but in the subclasses you want it to be required you can simply invalidate the property's value when it's nil or empty, and even make it depend on other factors.

JoostK