News

 
  • 21 May

    New in RubyMotion: BigDecimal, Better Localization

    The last RubyMotion releases introduced a couple high-level changes that we would like to cover, before we get to start our second developer conference, next week!

    BigDecimal

    As of RubyMotion 2.28, the BigDecimal class is introduced, based on top of Cocoa’s NSDecimalNumber class.

    It implements all of CRuby’s BigDecimal operator methods, and can be passed to Objective-C APIs that expect arguments as NSDecimalNumber objects, NSDecimal structures, or pointers to NSDecimal structures.

    NSDecimalNumber objects are therefore not converted to Float objects anymore, and remain intact when passed to and retrieved from Objective-C APIs.

    In case your application requires high-precision representations for floating point objects, we recommend using BigDecimal instead of Float.

    (main)> x = BigDecimal.new('0.123456789')
    => 0.123456789
    (main)> x + 1
    => 1.123456789
    

    Better Localization

    The build system has been improved to detect and properly compile strings resource files into the application bundle. This patch was contributed by Hwee-Boon Yar.

    Additionally, the NSLocalizedString() API and its variants, NSLocalizedStringFromTable(), NSLocalizedStringFromTableInBundle() and NSLocalizedStringWithDefaultValue(), have been added as methods of the Kernel module. Previously they were not available as they are C-level preprocessor macros, and one had to call the NSBundle Objective-C API directly.

    String resource files are usually used to localize an application, by providing the translations of user interface strings. A resource file per localization is the norm.

 
 

Want to stay in touch?

Follow us on Twitter