[MacRuby-devel] calling Objective-C method with block parameter
Eloy Duran
eloy.de.enige at gmail.com
Wed Nov 17 05:42:55 PST 2010
The BridgeSupport file should be in a BridgeSupport directory inside the framework’s Resources directory. For example, Foundation’s BridgeSupport file is at: /System/Library/Frameworks/Foundation.framework/Resources/BridgeSupport/Foundation.bridgesupport
On Nov 17, 2010, at 2:32 PM, Alan Skipp wrote:
> Thanks for the info. I'd wrongly assumed that as blocks can be treated as Objective-C objects that I could just go ahead and use them in Macruby.
> I have it working now, which is great, though I do have one more question.
> Initially I was receiving the same errors after I'd included the framework with a bridgesupport file into my project. I finally got it working after invoking, 'load_bridge_support_file' in my controller class. Is there something I should be doing that would enable macruby to automatically detect and load the bridgesupport file included in my framework?
>
> Cheers,
> Al
>
> On 16 Nov 2010, at 22:23, Thibault Martin-Lagardette wrote:
>
>> Also, it is to note that if the block lives inside a framework you've made (or downladed – one that is not part of the system), you'll have to generate the BridgeSupport files yourselves.
>> This is important because the runtime needs to know that you're trying to use blocks, and you instruct it to use them by creating and using the said BridgeSupport files :-)
>>
>> --
>> Thibault Martin-Lagardette
>>
>>
>>
>> On Nov 16, 2010, at 23:10, Matt Aimonetti wrote:
>>
>>> Did you install BridgeSupport preview 1? http://www.macruby.org/blog/2010/10/08/bridgesupport-preview.html
>>> It is required to use C blocks.
>>>
>>> Thanks,
>>>
>>> - Matt
>>>
>>>
>>> On Mon, Nov 15, 2010 at 2:51 AM, Alan Skipp <al_skipp at fastmail.fm> wrote:
>>> 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”.
>>>
>>> _______________________________________________
>>> MacRuby-devel mailing list
>>> MacRuby-devel at lists.macosforge.org
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>>
>>>
>>> _______________________________________________
>>> MacRuby-devel mailing list
>>> MacRuby-devel at lists.macosforge.org
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101117/a988e6af/attachment.html>
More information about the MacRuby-devel
mailing list