rubymotion-community / BubbleWrap

Cocoa wrappers and helpers for RubyMotion (Ruby for iOS and OS X) - Making Cocoa APIs more Ruby like, one API at a time. Fork away and send your pull requests
Other
1.18k stars 208 forks source link

undefined method `trigger' for #<BubbleWrap::Reactor::PeriodicTimer... #259

Closed mlohr closed 11 years ago

mlohr commented 11 years ago

When using BW 1.3.0 and a simple periodic timer:

@timer = EM.add_periodic_timer 1.0 do
    p "tick"
end

My app crashes with the undefined method 'trigger' error.

In my Rakefile I have:


require 'bubble-wrap/core'
require 'bubble-wrap/reactor'

When I uncomment line 25 (trigger(:fired)) from periodic_timer.rb the code works as expected.

I am using motion 2.2

clayallsopp commented 11 years ago

Can you confirm if motion/reactor/eventable.rb shows up somewhere in the build output? (after a rake clean build)

mlohr commented 11 years ago

Confirmative:

Compile /Users/michel/.rvm/gems/ruby-1.9.3-p362/gems/bubble-wrap-1.3.0/motion/reactor/eventable.rb
clayallsopp commented 11 years ago

If you immediately run @timer.cancel, do you get the same error?

mlohr commented 11 years ago

When using EM.cancel_timer(@timer)then I am getting the same error.

mlohr commented 11 years ago

After further investigation when I include the trigger method into PeriodicTimer:

  1. without modification I get the same error.
  2. with the next modification (removing the *args parameter) I do not get an error:

def trigger(event, *args) into def trigger(event)

mlohr commented 11 years ago

Interesting, I have replayed the behavior (from my last comment) with irb and REPL:

class A
   def trigger event, *args
      p "hi"
   end
end

a = A.new
a.trigger :hi

With irb, I get no error With REPL I get the error: undefined methodtrigger' for # (NoMethodError)`

Could this be a bug in Rubymotion? I just upgraded to motion 2.3 and this error persists...

seanlilmateus commented 11 years ago

actually #trigger is defined in Eventable module, we may have an issue loading this module. it works when running from command line :-/

mlohr commented 11 years ago

@seanlilmateus: doesn't seem so, see my last comment pls 4 mins ago

Please try replicate it yourself in REPL

mlohr commented 11 years ago

Creating a new vanilla project with only the timer does not result into issues...
The question remains how to fix my current project?

mlohr commented 11 years ago

Got it! some cocoapod I use has a category on NSObject which uses #trigger as well : (

I will close this issue now, thanks to @seanlilmateus and @clayallsopp for your help.

Cheers, Michel