<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Laurent,<div><br></div><div>(sorry for the longish post)</div><div><br></div><div>I did some simple tests where the bound variable is not actually bound to a CoreData store, but to a method in the custom NSManagedObject class..</div><div><br></div><div>(btw - I am not sure if anyone else noticed but a difference between 0.4 and 0.5, is that when binding to custom methods now, the methods have to be mentioned in the valueForUndefinedKey method of the NSManagedObject - before they did not need to be - but maybe in 0.4, this was a lucky time dependency, with the method being loaded before being queried by the view).</div><div><br></div><div>- Returning a (ruby) number like 45.3 will not be displayed in the column (with and without formatter) or in fact a plain NSTextField (so it does not seem to be a table cell issue) but returning&nbsp;NSDecimalNumber.decimalNumberWithString("45.3") - will be displayed correctly in both.</div><div><br></div><div>- Same issue when binding to a class with only NSObject as the super.</div><div><br></div><div>- I also did do some test with the core data stack and KVC/KVO, binding etc and everything worked ok. I now think this issue has nothing to do with CoreData.</div><div><br></div><div>- My current suspicion is that the&nbsp;NSTextField&nbsp;is being sent a&nbsp;<b>setObjectValue</b> message which works fine with NSDecimalNumbers - it does not work with MacRuby Floats, or with NSNumbers - although i would expect it to since they are objects.</div><div><br></div><div>(bolds added by me for comprehension)</div><div><br></div><div><div>irb(main):005:0&gt; <b>framework "Cocoa"</b></div><div><b>=&gt; true</b></div><div>irb(main):006:0&gt; <b>tf = NSTextField.alloc.init</b></div><div><b>=&gt; #&lt;NSTextField:0x20026c560&gt;</b></div><div>irb(main):007:0&gt; <b>num = NSNumber.numberWithFloat(23.3)</b></div><div><b>=&gt; 23.2999992370605</b></div><div>irb(main):008:0&gt; <b>tf.setObjectValue(num)</b></div><div><b>=&gt; #&lt;NSTextField:0x20026c560&gt;</b></div><div>irb(main):009:0&gt; <b>p tf.stringValue</b></div><div><b>"0"</b></div><div><b>=&gt; "0"</b></div><div>irb(main):010:0&gt;<b> tf.setFloatValue(23.3)</b></div><div><b>=&gt; #&lt;NSTextField:0x20026c560&gt;</b></div><div>irb(main):011:0&gt; <b>p tf.stringValue</b></div><div><b>"23.29999923706055"</b></div><div><b>=&gt; "23.29999923706055"</b></div><div><br></div><div>I will add this to the MacRuby bugs a bit later.</div></div><div><br></div><div><div><br></div></div><div>re NSDecimalNumber -&gt; leaving it "untouched" as you said, &nbsp;is, &nbsp;in my opinion the right thing, it would be too confusing for it to have different behavior than what is in the docs.</div><div><br></div><div>Cheers,</div><div>John</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><div><div>On Nov 27, 2009, at 9:22 PM, Laurent Sansonetti wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi John,<br><br>This may be a bug in MacRuby, I don't know bindings well enough. It would be cool if you could reduce the problem into a small Ruby script.<br><br>We are indeed unboxing NSNumbers automatically. NSDecimalNumber seems to be left untouched, which could explain why the normal arithmetic operators do not work.<br><br>Laurent<br><br>On Nov 27, 2009, at 7:50 AM, John Shea wrote:<br><br><blockquote type="cite">Hi all,<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">does any one know whether there is an issue with binding to floats, doubles in core data with macruby?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">For example:<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">1 I firstly, create an attribute foo which is set as a double or a float in the core data model<br></blockquote><blockquote type="cite">2. i bind it to a table column<br></blockquote><blockquote type="cite">3. I set foo to 300.3 in code (not through the user interface)<br></blockquote><blockquote type="cite">4. it comes through as 1 (or 1.00 if formatted - which is probably neither here nor there)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">If i do the same but set the attribute to be of type decimal - then the number 300.3 comes through fine.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The problem then is that is that the class of foo is NSDecimalNumber - and its really painful doing calculations with NSDecimalNumbers given that normal arithmetic operators do not work.<br></blockquote><blockquote type="cite">I haven't found it to be that accurate either (at least in Objective C) - compared to ruby floats.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">The strange thing is that both end up (in macruby) inheriting from NSNumber - but somehow the binding cannot make sense of it.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Is it possible that there is a non macruby translation going on? - an unboxing - because the binding/kvc access thinks that foo is a float? (which it might be, in the persistent store - but does not seem to be by the time its accessed).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">I can think of work arounds - but i thought i better check with the experts first ;-).<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Cheers,<br></blockquote><blockquote type="cite">J<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">MacRuby-devel mailing list<br></blockquote><blockquote type="cite"><a href="mailto:MacRuby-devel@lists.macosforge.org">MacRuby-devel@lists.macosforge.org</a><br></blockquote><blockquote type="cite"><a href="http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel">http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel</a><br></blockquote><br>_______________________________________________<br>MacRuby-devel mailing list<br><a href="mailto:MacRuby-devel@lists.macosforge.org">MacRuby-devel@lists.macosforge.org</a><br>http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel<br></div></blockquote></div><br></div></body></html>