[MacRuby-devel] Cocoa Binding to NSArrayController

steve ross cwdinfo at gmail.com
Tue Jan 12 19:37:47 PST 2010


Yes, this appears to be the bug, and yes, this is an absolutely great (!!!) temporary fix. Thanks very much for this.

Steve

On Jan 12, 2010, at 5:48 PM, John Shea wrote:
> Perhaps it is this bug here: https://www.macruby.org/trac/ticket/473
> 
> In my case with the current 0.5 beta2 no float or integer binding to nscontrol works (I get all 1's) unless the float or integer is converted to an NSDecimalNumber using a ValueTransformer.
> This is what i use for each float binding as a work around:
> 
> class ToDecimalTransformer < NSValueTransformer 
> 	def self.transformedValueClass; NSDecimalNumber.class; end
>  	
> 	def self.allowsReverseTransformation; true; end 
>   	
> 	def transformedValue(value)
>     		NSDecimalNumber.decimalNumberWithString(value.to_s)
>  	 end
>   
>   	def reverseTransformedValue(value)
> 	  	new_val = value.to_f
>   	end
> end
> 
> HTH,
> John
> 
> On Jan 12, 2010, at 7:33 PM, steve ross wrote:
> 
>> On Jan 11, 2010, at 11:13 AM, isaac kearse wrote:
>>> Looks like you're bypassing the to_i conversion of @number by calling instance_variable_set directly, but I'd guess that the problem is somewhere else in the app.
>>> Any chance you could put the whole thing up on github?
>>> 
>>> Cheers,
>>> Isaac
>> 
>> I put together an Objective-C version of this same thing and checked it into the github project for comparison. It works. I'm sure there's something different in how I'm using it, but I can't see what. The project is at:
>> 
>> git at github.com:sxross/MacRuby-Array-Cocoa-Array-Binding.git
>> 
>> That's both MacRuby and Objective-C. Any pointers to my blind spot are appreciated :)
>> 
>> Steve
>> 
>>> On Tue, Jan 12, 2010 at 6:41 AM, steve ross <cwdinfo at gmail.com> wrote:
>>> I wrote a simple controller that binds to an NSTableView. In the tableview, a column has an NSNumberFormatter (in IB), but the column is what's bound. It's bound to LightboxController.managedObjects:number. The managedObjects collection contains a collection of Lightbox objects, that have a number (Fixnum, when examined) and a title (string). The title displays fine, but the number always displays as 1. Changing the number field to a string and removing the NSNumberFormatter produces the correct display, but of course, the sort order is string ordering rather than numeric.
>>> 
>>> Here is the code. Can anyone tell me what I'm missing here?
>>> 
>>> https://gist.github.com/5d490492a814eccd26b2
>>> 
>>> Thx,
>>> 
>>> Steve


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20100112/8b156027/attachment.html>


More information about the MacRuby-devel mailing list