Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Kernel's sprintf / format / % method broken in apps #4

timbogit opened this Issue · 5 comments

4 participants


While trying to run the Timer sample app, I discovered that Kernel#sprintf is broken:
--- snip ---

tim-schmelmers-macbook:Timer tim$ rake
(in /Users/tim/ruby_motion/RubyMotionSamples/Timer)
Build ./build/iPhoneSimulator-5.1-Development
Compile ./app/timer_controller.rb
Link ./build/iPhoneSimulator-5.1-Development/
Create ./build/iPhoneSimulator-5.1-Development/Timer.dSYM
Simulate ./build/iPhoneSimulator-5.1-Development/
(main)>> res = "%.1f" % 0.2123
=> "%.1f"
(main)>> res = sprintf("%.1f",0.2123)
=> "%.1f"
(main)>> res = format("%.1f",0.2123)
=> "%.1f"
--- snap ---

This seems to work with the ruby interpreter that comes with Ruby Motion, though ...
--- snip ---
tim-schmelmers-macbook:~ tim$ /Library/RubyMotion/bin/ruby -e 'puts format("%.1f",0.2123)'
--- snap ---


Confirmed. I'm 99% sure this worked fine in RubyMotion 1.0, though I can't check now that I've updgraded. Now, whenever I try to use sprintf or NSString.stringWithFormat, I get unexpected results. I filed an official support ticket as well.

lrz commented

A fix for this problem will ship in tonight's build (if there is one) or tomorrow. Sorry about the inconvenience.

lrz commented

Should be fixed by RubyMotion 1.3

@lrz lrz closed this

confirmed fixed, thanks for the quick action!


Hey Guys, I think this is not totally fixed. I have an app that is using sprintf to fill in some labels, but when I use sprintf my simulator (motion 1.30, OS 10.7.5) throws a ton of "pointer being freed was not allocated" messages and if I try to run on my device (iPad mini iOS 6.0.2) the app crashes outright. If I replace sprintf with just a hardcoded string it runs with no errors on the simulator and on the device.

Any ideas on what might be going on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.