I must be doing something really obviously wrong, but I can't see it.
+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
2010-10-30 10:14:52
I believe NSDouble is the objective C counterpart, please correct me if I'm wrong.
Joe D
2010-10-30 10:15:52
@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
2010-10-30 10:17:39
+1
A:
Just converting mentioned above is good enough though you might want to use floor() or ceil() functions before that.
Vladimir
2010-10-30 10:24:07
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
2010-10-30 12:41:33