I wanted to create a value transformer that would convert a BOOL value to either a Yes or No string, for displaying data using bindings. However, the method that must be overriden in a NSValueTransformer subclass, - (id)transformedValueid)value, expects an object to be passed in. As I am passing in a boolean, the only way I have found that works is this:
However, this is obviously really hacky, and also makes the NSTextField subviews that are bound to the value with the transformer applied redraw in a strange way.
I'm sure there must be a better way of converting booleans to text, does anyone have any pointers?
Code:
- (id)transformedValue:(id)value
{
if ((int)value == 16866128)
{
return @"Yes";
}
return @"No";
}
However, this is obviously really hacky, and also makes the NSTextField subviews that are bound to the value with the transformer applied redraw in a strange way.
I'm sure there must be a better way of converting booleans to text, does anyone have any pointers?