[MacRuby-devel] Out parameters with MacRuby

Laurent Sansonetti lsansonetti at apple.com
Sun Apr 26 19:14:15 PDT 2009

Hi Alex,

On Apr 26, 2009, at 6:20 PM, Alex Vollmer wrote:

> On Apr 26, 2009, at Apr 26, 10:09 AM, rebotfc wrote:
>> errorp = Pointer.new_with_type("@")
>> result = NSXMLDocument.alloc.initWithData(data,  
>> options:NSXMLDocumentValidate, error:errorp)
>> # access error
>> errorp[0]
> Ah cool. Thanks for the response. Is there any documentation on the  
> possible values you can hand to the "new_with_type" method? What  
> does that '@' sign mean?


In the case of a C structure, you can call the #type class method on  
the struct class.

$ macirb
irb(main):001:0> framework 'Foundation'
=> true
irb(main):003:0> NSRect.type
=> "{CGRect={CGPoint=dd}{CGSize=dd}}"

The next version of MacRuby will have a better Pointer class which  
will accept symbols like :int, :object, etc., but in the meantime you  
need to pass the Objective-C types.


More information about the MacRuby-devel mailing list