validating relationships
validating relationships
- Subject: validating relationships
- From: "Jim Thomason" <email@hidden>
- Date: Wed, 25 Jul 2007 08:33:58 -0500
This seems like it should be easy to me, but I haven't been able to
find any definitive answers.
Where should I validate a relationship in a coredata app as it is
being created? Validating properties is no sweat, but validating
relationships eludes me.
For a very contrived example that demonstrates the point, let's say I
have a person entity that has many coats. For some silly reason,
there's a constraint in the system that says you can have only one
blue coat. Further, "blue" is the default coat color.
So in my interface, I can navigate over to my Person and go to the
Coats table. From there, I can add a coat. It defaults to "blue". No
problem. But I can then add another coat, which also defaults to
"blue". This is a problem.
Now, I can catch it upon save and pop up an error ("Dude! One blue
coat!"), but ideally I'd like to just prevent the extra blue coat from
being created. But I haven't figured out where I should put the code
to do it.
Coat -awakeFromInsert? Person -addCoatObject? NSArrayController
-addObject? Some validate method I haven't found? Should it even be
done at this point, or do I just need to wait until save to fix it?
-Jim.....
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden