[英]How to take these parameters the same way this function does?
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. 如您所见,该方法仅接收NSDecimal的这两种类型,leftOperand和rightOperand。 Then it passes them on to a C API function which likes to have them by reference.
然后将它们传递给C API函数,该函数喜欢通过引用获得它们。 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?
我如何将这些传递给NSDecimalCompare函数?
I slighlty remember there was some dereferencing operator around for that? 我很高兴地记得周围有一些解引用运算符吗?
Try: 尝试:
- (BOOL)compare:(const NSDecimal*)leftOperand greaterThan:(const NSDecimal*)rightOperand {
NSComparisonResult result = NSDecimalCompare(leftOperand, rightOperand);
// rest not important
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.