[MacRuby-devel] handling void pointers in callbacks

Laurent Sansonetti lsansonetti at apple.com
Sat Jan 9 01:51:54 PST 2010

Hi Michael,

I recommend not to use this argument in MacRuby at this point. it is  
safer to pass a value by assigning it as an instance variable of the  
observer/delegate/whatever receiver object instead, using  


On Jan 9, 2010, at 12:01 AM, Michael Johnston wrote:

> I'm working through the PragProg Core Data book, and have  
> encountered an issue passing contextInfo to  
> NSOpenPanel.beginSheetForDirectory
> This issue was discussed on the list previously by Dr. Nic: http://www.mail-archive.com/macruby-devel@lists.macosforge.org/msg00330.html
> The problem is that there doesn't seem to be a way to cast an object  
> pointer to a void pointer in Macruby, but when openPanel calls the  
> callback assigned in didEndSelector it does cast the pointer passed  
> in contextInfo to a void pointer, leading to a type error when the  
> callback is called:
> {{{
> 2010-01-08 23:44:49.580 GrokkingRecipesRuby[34059:10b] expected  
> instance of Pointer of type `v', got `@'
> }}}
> I tried assigning my object to a Pointer.new('^v') and Pointer.new 
> (:uchar) but this also caused type errors.
> is there any workaround for this?
> Cheerio,
> Michael Johnston
> lastobelus at mac.com
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

More information about the MacRuby-devel mailing list