views:

18

answers:

0

How can I implement this validation in Cocoa?

My Situation is:

Model: An object names Person, with a name property. And an NSArray of Person objects,

View: NSTableView, it uses data-binding to bind with the Person object array. The NSTableView has in-place editing function enabled.

When user finish editing the name in NSTableView, I need check if the Person's name already exists in the Array.

I read the key-value Validation document. It looks KVC will help call validate:error: method on the bound object. So in my case, it should be the Person object. But the Person Object cannot access the whole array, I cannot check for duplication in the method.

Can anyone point me how to use key-value Validation to handle this case?

Thanks!

-Jonny