[MacRuby-devel] calling Objective-C method with block parameter

Alan Skipp al_skipp at fastmail.fm
Mon Nov 15 02:51:00 PST 2010


Hello everyone,
I'm attempting to call a method on an Objective-C object which takes a block as its parameter, but I'm not having much luck.  I can happily create the object in Macruby and send the message with a Proc. The NSLog call within the Objective-C method body succeeds, but the 'block()' doesn't. Am I doing something obviously wrong here? (I'm using a nightly build from sometime last week).


This is the Objective-C method:

- (void)callBlock:(void (^)())block;
{
	NSLog(@"block: %@", block);
	block();
}

Here is the ruby code:

b = TestBlock.new
b.callBlock( Proc.new { puts "hello" } )


The output is as follows:

block: #<Proc:0x2005c9b80>
Program received signal:  “EXC_BAD_ACCESS”.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101115/00cd73b8/attachment.html>


More information about the MacRuby-devel mailing list