objective c - i get data in meter in nsnumber from api but how will i convert it into km -
my code below
nsnumber *somenumber = [[_dict2 objectforkey:@"location"] objectforkey:@"distance"]; nsstring *somestring = [somenumber stringvalue]; _lbldistance.text=somestring;
if want include km
in string use nslengthformatter
nsnumber *somenumber = @1568; nslengthformatter *formatter = [[nslengthformatter alloc] init]; nsstring *distanceinkm = [formatter stringfrommeters:somenumber.doublevalue]; nslog(@"%@", distanceinkm); // 1.568 km
Comments
Post a Comment