A O A O - 4 months ago 35
Objective-C Question

Is it possible to programmatically access the NSValueTransformer associated with my cocoa binding?

The reason isn't important, because I know this is bad, but it's just for curiosity. The better way, what we are going to do is just have the transformer access a shared instance to update a

property, instead of somebody else setting it on the transformer.

But is there any way to access the options on a cocoa binding programmatically, and more specifically, access the current transformer?


Yes, you can access the transformer:

options = [[textfield infoForBinding:NSValueBinding] objectForKey:NSOptionsKey];
valueTransformer = [options objectForKey:NSValueTransformerBindingOption];