Strange troubles and snags - ParkinT/RubyMotion_Life GitHub Wiki
Troubles, Gotchas, "Undocumented Features"
This page is a collection of things uncovered by the RubyMotion community. We expect, over time, many of these holes will be plugged. But, until then, if yourself frustrated and bewildered by a problem the answer may be here.
App hangs on device although it works in simulator
Blocks
Returning from a function from within a block will work in the simulator, but will cause the app to hang indefinitely when run on an actual device. Here is an illustration of the problem:
Before:
target.class.ancestors.each do |ancestor|
if Teacup.handlers[ancestor].has_key? key
NSLog "#{ancestor.name} is handling #{key} = #{value.inspect}" if target.resp
Teacup.handlers[ancestor][key].call(target, value)
return
end
end
Fixed:
handled = false
target.class.ancestors.each do |ancestor|
if Teacup.handlers[ancestor].has_key? key
NSLog "#{ancestor.name} is handling #{key} = #{value.inspect}" if target.resp
Teacup.handlers[ancestor][key].call(target, value)
#return
handled = true
break
end
end
return if handled
Be sure to also checkout this page.