RubyCocoa and addresses of pointers

Some methods in Objective-C require the address of a pointer, so the method
can fill in the value of the pointer. How do I do this in RubyCocoa?

As an example, here’s some Objective-C code

// fpDate is an IB outlet
NSDateFormatter *dateFormatter = [fpDate formatter];
NSCalendarDate *templateDate;
BOOL conversionResult;
NSString *error;
BOOL conversionResult;

conversionResult = [dateFormatter getObjectValue:&templateDate
				   forString:[fpDate stringValue]
			    errorDescription:&error];

getObjectValue:forString:errorDescription: takes two arguments that are
addresses of pointers. The method returns objects in those parameters.

Is there a way to do this in RubyCocoa?

Jim

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“SPOON!” – The Tick’s battle cry
"Not in the face! Not in the face!" – Arthur’s battle cry

I wrote:

Some methods in Objective-C require the address of a pointer, so the method
can fill in the value of the pointer. How do I do this in RubyCocoa?

I think I’ve answered my own question. You need to initialize the variable
to the type of the object that is needed. For example,

    templateDate = NSObject.alloc.init
    errorString = NSString.alloc.init
    conversionResult = dateFormatter.getObjectValue_forString_errorDescription(templateDate, @fpDate.stringValue, errorString)

At least, it works and my app doesn’t crash any more. That’s good enough
for me.

Jim

···


Jim Menard, jimm@io.com, http://www.io.com/~jimm/
“The theory of computation states that all automatons can be emulated by a
Turing machine. I have a less abstract but more practical motto: If you can
do it on Intel, you can do it damn near anywhere!” – Eugene O’Neil