krata
krata

Reputation: 101

Core data - double attribute - basic mathematical operations

I have in CoreData a entity. It has a attribute "score". The score has type double, but when I want to work with the number, xcode shows, that is a NSNumber, not double. So, I can't use basic mathematical operations. I need increment,decrement,devide etc. How can I do it please?

Upvotes: 2

Views: 203

Answers (1)

Amin Negm-Awad
Amin Negm-Awad

Reputation: 16660

  1. You can read out the stored value with -doubleValue (NSNumber).

  2. You can select Decimal instead of Double- IIRC you will get instance objects of NSDecimalNumber.

BTW: Using double for a score will lead to surprising behavior. You shouldn't do that either way. Decimals or integers treated as fixed-point would be the better choice.

Upvotes: 2

Related Questions