开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜