views:

95

answers:

1

For example:

- (BOOL)compare:(NSDecimal)leftOperand greaterThan:(NSDecimal)rightOperand {
    NSComparisonResult result = NSDecimalCompare(&leftOperand, &rightOperand);
    // rest not important
}

like you can see, the method just receives these two types of NSDecimal, leftOperand and rightOperand. Then it passes them on to a C API function which likes to have them by reference. Sorry if that's the wrong term, didn't study that stuff. Currect me if I'm wrong :-)

I want to modify this method in such a way, that I can also accept parameters the way that function does. I think that's clever, because the method won't copy the parameters (I believe it does). What would I have to add in there in order to get this reference thing right? And after that, my parameters are just references, right? How would I pass these then along to the NSDecimalCompare function?

I slighlty remember there was some dereferencing operator around for that?

+5  A: 

Try:

- (BOOL)compare:(const NSDecimal*)leftOperand greaterThan:(const NSDecimal*)rightOperand {
    NSComparisonResult result = NSDecimalCompare(leftOperand, rightOperand);
    // rest not important
}
fbrereto