[MacRuby-devel] Bug: NSValueTransformer receivers NSCFNumber, not fixnum

Brian Marick marick at exampler.com
Thu Feb 12 07:03:52 PST 2009


Is this a bug? I don't see anything quite like it in Trac.

I have a binding to a button's state property. Here's the binding:

    @comboBox.bind 'enabled',
              toObject: @button,
              withKeyPath: 'state',
              options: {
                          NSValueTransformerBindingOption =>
                          OffStateMeansTrueTransformer.alloc.init
                        }

At the point the binding is made, the state of the button is a fixnum 0.

The value transformer is immediately called to set the starting value.  
Here's the transformedValue code:

  def transformedValue(state)
    puts "state -> bool transforming #{state.inspect}"
	# prints #<NSCFNumber:0x1022180>
	# state.intValue is 0

Because of this, I have to cast the state before making comparisons:

    case state.intValue
    when NSOffState then true
    when NSOnState then false
    else
      raise "The value to transform should be either NSOffState or  
NSOnState."
    end


If this is a bug, I'll write a testcase.

-----
Brian Marick, independent consultant
Mostly on agile methods with a testing slant
www.exampler.com, www.exampler.com/blog, www.twitter.com/marick



More information about the MacRuby-devel mailing list