[MacRuby-devel] Out parameters with MacRuby

Alex Vollmer alex.vollmer at gmail.com
Sun Apr 26 08:36:57 PDT 2009


Is it possible to use "out" parameters with MacRuby, such as NSError?  
In my particular case I'd like to capture errors that result from  
parsing XML with NSXMLDocument using the initWithData:options:error:  
method. I tried (naively) just instantiating an NSError instance and  
handing it to that method, but ended up with this:

irb(main):037:0> e = NSError.new
=> #<NSError:0x80067cc40>
irb(main):038:0> doc = NSXMLDocument.alloc.initWithData(data,  
options:NSXMLDocumentValidate, error:e)
ArgumentError: can't convert Ruby object `#<NSError:0x80067cc40>' to  
Objective-C value of type `^@'
	from (irb):38:in `initWithData:options:error:'
	from (irb):38
	from /usr/local/bin/macirb:12:in `<main>'

Any help or insight is appreciated.

Cheers,

Alex
----
Musings & Notes — http://alexvollmer.com
Track what you lend and borrow — http://moochbot.com







More information about the MacRuby-devel mailing list