Operand for NSDecimalNumber
When I started to learn Objective C, that is hard to understand the NSDecimalNumber. I am C# and Java Programmer, in these languages, we used the primitive, such as integer and long, I can just use - and + as operand. However, in IOS, the most of situations, we are using NSDecimalNumber. That is an object. So, you cannot use + and -. If you write this, it will cause error:
Code
NSDecimalNumber *percent = self.tiprecord.tip/ self.tiprecord.total |
You should use such operands:
decimalNumberByAdding = +
decimalNumberBySubtracting = -
decimalNumberByMultiplyingBy = *
decimalNumberByDividingBy = /
For Example:
Code
NSDecimalNumber *percent = [self.tiprecord.tip decimalNumberByDividingBy: self.tiprecord.total ] |
Trackback address for this post
Trackback URL (right click and copy shortcut/link location)
Feedback awaiting moderation
This post has 11 feedbacks awaiting moderation...
Form is loading...