tags:

views:

177

answers:

1

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 suggestions?

THANKS!

+1  A: 

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

Kevin Panko