Re: No validation with a bound NSTableView and custom NSFormatter
Re: No validation with a bound NSTableView and custom NSFormatter
- Subject: Re: No validation with a bound NSTableView and custom NSFormatter
- From: Quincey Morris <email@hidden>
- Date: Tue, 01 May 2012 19:42:57 -0700
On May 1, 2012, at 19:20 , Ben Kennedy wrote:
> The issue I'm still having is that non-bound columns (i.e., those controlled by the latter two NSTableViewDataSource methods) are not enforcing validity when the attached formatter returns NO from getObjectValue:forString:errorDescription:.
I don't know that I've ever had to deal with this specific scenario, but examination of the documentation leads to the following observations:
1. You can implement a table view delegate that conforms to the NSTableViewDelegate protocol.
2. That's a sub-protocol of the NSControlTextEditingDelegate protocol.
3. That protocol has a method 'control:isValidObject:'.
4. The documentation of that method:
> https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/NSControlTextEditingDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intf/NSControlTextEditingDelegate
says this:
> "This method gives the delegate the opportunity to validate the contents of the control’s cell (or selected cell). In validating, the delegate should check the value in the object parameter and determine if it falls within a permissible range, has required attributes, accords with a given context, and so on. Examples of objects subject to such evaluations are an NSDate object that should not represent a future date or a monetary amount (represented by an NSNumber object) that exceeds a predetermined limit."
That seems like what you want, if you query the formatter directly from this delegate method.
Whether NSTableView has an automated mechanism for querying the formatter itself, I don't know, and I can't find any documentation that suggests it might.
I bet there's an easier answer staring us right in the face.
_______________________________________________
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