[ACCEPTED]-Objective-C, how do I convert a double to an int?-xcode
Accepted answer
A double is a C type, not an Objective-C 1 object. Hence you use C casts:
double myDouble = 3.2;
int myInt = (int)myDouble;
Just converting mentioned above is good 2 enough though you might want to use floor() or 1 ceil() functions before that.
intValue is a method for a NSNumber instance. For scale 5 type like int, double, and float, they are 4 not class type. So, they have no methods. Some 3 languages like C# may wrap int, or double 2 as a object, and they can be transfered 1 to each other by a sub-routine.
try this
NSInteger number=33;
NSUInteger count = (NSInteger)[number];
here, NSUInteger is long. number is NSInteger
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.