CLLocationSpeed Issue
I'm trying to get my code to return the velocity of the device in miles per hour with the following:
double speed = newLocation.speed;
NSString *speedyspeed = [NSString stringWithFormat:@"%d", (speed*2.2369)];
yourSpeed.text = speedyspeed;
the "speed*2.2369" is supposed to correct for the fact that the speed is returned in meters/second rather than miles/hour like I want. Regardless, I'm getting values of, like, -173498723 instead of normal values. I'm clearly doing something wrong. The speed value string is then assigned to output to my UILabel called "yourSpeed".
Any su开发者_开发百科ggestions?
THANKS!
You should use %f instead of %d as you are using a double, and not an integer.
Source: String Programming Guide for Cocoa - String Format Specifiers
精彩评论