RubyCocoa - selectors for Ruby classes

Discussion in 'Ruby' started by Gabriele Marrone, Nov 3, 2006.

  1. Hello.
    I'm using the RubyCocoa framework (well, trying to), freshly compiled
    today (oops, yesterday) from the svn stable repository.

    I want my application controller to get asynchronous notifications
    when a file descriptor has new data to be read, so I decided to use
    OS X infrastructure.
    Here is the interesting part of the code:


    class Controller < OSX::NSObject
    addRubyMethod_withType('dataAvailable:', 'v@:mad:')
    def dataAvailable(obj)
    # do something
    end
    def setup_notification_observer

    OSX::NSNotificationCenter.defaultCenter.addObserver_selector_name_object
    (
    self,
    'dataAvailable:',
    "NSFileHandleDataAvailableNotification",
    @fileHandle
    )
    end
    def setup_data_available_notification
    @fileHandle.waitForDataInBackgroundAndNotify
    end
    ...
    end


    Of course setup_data_available_notification and
    setup_notification_observer are called by awakeFromNib.

    Everything should be right, but when the default center tries to send
    my Controller a message I get logged:


    2006-11-03 00:46:37.262 Fango[19411] Exception raised during posting
    of notification. Ignored. exception: *** -[NSProxy
    forwardInvocation:] called!


    It looks like it can find the method signature (provided by
    addRubyMethod_withType), but the forwardInvocation: method of the
    Objective-C wrapper to my ruby Controller class doesn't actually call
    my ruby method. In fact, this makes me suppose forwardInvocation:
    isn't overrided at all and the message is catched by the parent class
    which raises an exception, but I haven't read RubyCocoa source code
    so I can't be sure.

    I followed closely what's written here: http://www.rubycocoa.com/
    appleremote/2 . I double checked Apple documentation of
    NSNotificationCenter, NSFileHandle.
    I also searched on google for other documentation about selectors and
    RubyCocoa, but all I could get was code with japanese comments which
    didn't use addRubyMethod_withType at all. I guess that code was for
    another version of RubyCocoa (newer, maybe? From the unstable
    repository?).

    This is what I tried:
    - removing addRubyMethod_withType
    - adding ns_override
    - using :dataAvailable_, :dataAvailable, 'dataAvailable' instead of
    'dataAvailable:'
    - defining the method dataAvailable_ instead of dataAvailable
    - something else I can't remember :p
    Most of which I didn't expect to actually work, but decided to try
    anyway. Some bugs just make you paranoid.

    I'm using Mac OS X 10.4.8 (PPC), XCode 2.4.

    Any ideas? :)
    Thanks in advance!
     
    Gabriele Marrone, Nov 3, 2006
    #1
    1. Advertising

  2. Gabriele Marrone

    Harry Guest

    > I also searched on google for other documentation about selectors and
    > RubyCocoa, but all I could get was code with japanese comments which
    > didn't use addRubyMethod_withType at all. I guess that code was for
    > another version of RubyCocoa (newer, maybe? From the unstable
    > repository?).
    >
    >
    > Any ideas? :)
    >



    Hi,

    I don't know anything about RubyCocoa but I happened to see these
    links in the Japanese mailing list.
    They are in English.

    Hope it helps.

    http://rubycocoa.sourceforge.net/
    http://rubycocoa.sourceforge.net/doc/
    http://rubycocoa.sourceforge.net/doc/unstable/

    Harry


    --
    http://www.kakueki.com/ruby/list.html
     
    Harry, Jan 24, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luigi Donatello Asero

    Class selector, ID selectors and link pseudo-classes

    Luigi Donatello Asero, Jun 4, 2005, in forum: HTML
    Replies:
    4
    Views:
    536
    Luigi Donatello Asero
    Jun 4, 2005
  2. Luigi Donatello Asero
    Replies:
    1
    Views:
    415
    Luigi Donatello Asero
    Jun 4, 2005
  3. Phil Tomson
    Replies:
    8
    Views:
    113
    Ollivier Robert
    Mar 6, 2004
  4. jm
    Replies:
    7
    Views:
    132
  5. Ezra Zygmuntowicz

    Embed ruby inside rubycocoa app?

    Ezra Zygmuntowicz, Dec 27, 2005, in forum: Ruby
    Replies:
    0
    Views:
    131
    Ezra Zygmuntowicz
    Dec 27, 2005
Loading...

Share This Page