On Aug 14, 2013, at 6:28 PM, Rick Mann wrote: > I have a boolean property on an Entity for which only one should ever be > true. Is it really bad to implement a custom setter that loads every other > instance in the MOC that's true and sets them all to false? My code is > actually good about always clearing the current one before setting the new > one, but when I'm debugging, I will copy data over from another device, and > it can't clear the old one in this case.
I am not sure if it bad, but it sure smells funny ;-) Anyway, the issue may be more of the data approach. It is likely that the boolean attribute shouldn't belong to the entity at all--i.e. that the attribute is really for needed by some other object or process and is not a function of the entity. A cleaner approach, IMHO, is to have a holder entity whose sole attribute is a to-one relationship to your other entity. Think of it as a singleton that always exist and maintains the particular managed object. It also requires no code at all to maintain uniqueness--simply assign the relationship. HTH, Keary Suska Esoteritech, Inc. "Demystifying technology for your home or business" _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com