On Nov 6, 2015, at 15:23 , Luc Van Bogaert <luc.van.boga...@me.com> wrote:
> 
> In a tableview with a content binding and a value binding on the table cell 
> view textfields to the model's objectValue keypaths, I'm having trouble 
> getting the key-value validation to work correctly. In the model class, I 
> have implemented the required validation methods (validateKey(_ :) throws), 
> for each of the properties, but the validation method only seems to get 
> called for scallar types and not for eg. String types. I've made sure I 
> checked "Validates immediately" in the binding attributes.

a. When you edit the text fields, does the model String property get updated?

b. Can you show us an example function signature line for a scalar validation 
method, and one for a string validation method?

c. Can you show us an example of a model key path you’re using when binding to 
objectValue?

It occurs to me that there might be a bridging issue here. Note that the 
generic validation method (which is what routes the validation to a specific 
validate<Key> method) looks like this in the Swift version of 
NSKeyValueCoding.h:

            public func validateValue(ioValue: 
AutoreleasingUnsafeMutablePointer<AnyObject?>, forKey inKey: String) throws

It’s possible that the validate<Key> method declaration needs to be something 
like this. (According to this theory, the scalar validation works because the 
object<->scalar conversion happens within KVC, and so it’s staying within the 
Obj-C type world.)

Does the model object inherit from NSObject and/or conform to NSObject protocol?

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to