views:

91

answers:

3

I must be doing something really obviously wrong, but I can't see it.

alt text

+6  A: 

A double is a C type, not an Objective-C object. Hence you use C casts:

double myDouble = 3.2;
int myInt = (int)myDouble;
Georg
I believe NSDouble is the objective C counterpart, please correct me if I'm wrong.
Joe D
@Joe D: There's only NSInteger (which is a typedef to int *or* long depending on 32/64bit), but there's NSNumber, which wraps C data types into an object.
Georg
+1  A: 

Just converting mentioned above is good enough though you might want to use floor() or ceil() functions before that.

Vladimir
A: 

intValue is a method for a NSNumber instance. For scale type like int, double, and float, they are not class type. So, they have no methods. Some languages like C# may wrap int, or double as a object, and they can be transfered to each other by a sub-routine.

Toro