Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

noutram

macrumors newbie
Original poster
Jul 30, 2009
1
0
I've hit a problem with trying to validate data entered into a NSTableView

I have a table column bound to an NSArrayController subclass (bound to ArrangedObject.personname).

I have an NSTextField also bound to the the NSArrayController subclass (bound to selection.personname)

The NSArrayController is bound to an NSMutableArray

What works perfectly is when I edit text in the text field, the changes show up in the table, and vice-versa.

I enable "Validates immediately" for both the table column and the NSTextField bindings.


In the NSArrayController subclass, I implement a method
-(BOOL) validateValue: (id*)ioValue forKeyPath: (NSString*)inKeyPath error: (NSError **)outError

Now, when I edit my data via the NSTextField, in accordance with the doc reference below, this method is called and I can validate the data. This is great as I prefer to perform validation in the controller as my validation depends on all other members of the Array (each entry needs to be unique).

However, when I edit data in the TableView, this method does not get called. Maybe I need to follow a different naming convention?

I am referring to the section "Bindings Message Flow" in the following article:

http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaBindings/CocoaBindings.html
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.