Cocoa input validation for duplicate name how?
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 f开发者_如何学Cunction 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
Take a look at this page in documentation particularly section "User Updates a Value in the User Interface". Hope this helps.
精彩评论