[MacRuby] #1280: Developers should be able to invoke Objective-C blocks passed to a MacRuby method
#1280: Developers should be able to invoke Objective-C blocks passed to a MacRuby method ----------------------------------+----------------------------------------- Reporter: christian@… | Owner: lsansonetti@… Type: enhancement | Status: new Priority: major | Milestone: Component: MacRuby | Keywords: blocks ----------------------------------+----------------------------------------- MacRuby currently allows passing ruby Proc objects to ObjC methods that accept a block. However, It doesn't provide a way for ruby methods to invoke ObjC blocks. For example, I need a way to invoke blocks passed to a MacRuby method like this: {{{ def performRequest(request, success:success_callback, error:error_callback) result = ... # success_callback.call(result) # <-- Doesn't work! end }}} While I'm not aware of any Cocoa interfaces that require this, I'm using blocks in my own frameworks. In particular, I've defined a protocol that defines a method with callbacks: {{{ - (BOOL)performRequest:(id)request success:(void(^)(id result))success, error:(void(^)(NSError *))error; }}} I want to be able to write a ruby implementation of this protocol, for testing purposes. If for some reason the current syntax isn't sufficient to allow this, I thought it might be intuitive to mark blocks using the '&' operator, like this: {{{ def performRequest(request, success:&success_callback, error:&error_callback) # ... end }}} -- Ticket URL: <http://www.macruby.org/trac/ticket/1280> MacRuby <http://macruby.org/>
participants (1)
-
MacRuby