Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert speed: m/s to km/h

Tags:

objective-c

I am new to Objective-C and would like some help with converting MPS to KPH.

Below is my current string for speed. Can someone please point out what else is needed?

speed.text = newLocation.speed < 0 ? @"N/A": [NSString stringWithFormat:@"%d", (int)newLocation.speed];
like image 513
craig Avatar asked Dec 21 '22 13:12

craig


1 Answers

m/s to km/h = (m/s) * (60*60)/1000

Or 1m/s = 3.6km/h

float speedInKilometersPerHour = newLocation.speed*3.6;
if (speedInKilometersPerHour!=0) {speed.text = [NSString stringWithFormat:@"%f", speedInKilometersPerHour];}
else speed.text = [NSString stringWithFormat:@"No Data Available"];
like image 144
Jonathan King Avatar answered Mar 08 '23 08:03

Jonathan King