[MacRuby-devel] floats in core data
John Shea
johnmacshea at gmail.com
Fri Nov 27 07:50:33 PST 2009
Hi all,
does any one know whether there is an issue with binding to floats, doubles in core data with macruby?
For example:
1 I firstly, create an attribute foo which is set as a double or a float in the core data model
2. i bind it to a table column
3. I set foo to 300.3 in code (not through the user interface)
4. it comes through as 1 (or 1.00 if formatted - which is probably neither here nor there)
If i do the same but set the attribute to be of type decimal - then the number 300.3 comes through fine.
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.
I haven't found it to be that accurate either (at least in Objective C) - compared to ruby floats.
The strange thing is that both end up (in macruby) inheriting from NSNumber - but somehow the binding cannot make sense of it.
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).
I can think of work arounds - but i thought i better check with the experts first ;-).
Cheers,
J
More information about the MacRuby-devel
mailing list