Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 1, 2009, 12:08 PM   #1
BNZ1
macrumors regular
 
Join Date: Nov 2008
Location: London
CLLocationDistance converted from Meters to KM/Miles etc

Hi Guys,

First off, sorry for asking this if it is as simple as I think it should be..... I was trying really hard to not use the forums on my first app but my time has come.

Basically I have a database of locations and I am calculating the distance to them to organise them by relative closeness. When I do the CLLocationDistance.... command I get a float value returned in meters - e.g. 111125.113474. I want to convert this to KM (divide by 1000) but for the life of me can not work out how to do this!!!

Code:
CLLocationDistance distance = [objectLocation getDistanceFrom:currentLocation];
NSString *distanceString = [NSString stringWithFormat"@"%f", distance];

This code happily gives me a string with the value 111125.113474 but I cannot work out how to manipulate this string.

Thank you for your help!!
BNZ1 is offline   0 Reply With Quote
Old Apr 1, 2009, 12:21 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Divide by 1000 first, then convert to a string?
__________________
dejo is online now   0 Reply With Quote
Old Apr 1, 2009, 12:24 PM   #3
BNZ1
Thread Starter
macrumors regular
 
Join Date: Nov 2008
Location: London
Quote:
Originally Posted by dejo View Post
Divide by 1000 first, then convert to a string?
Come here, I am going to kiss you

Thanks!
BNZ1 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Trying to convert from PC to mac and need advice. liquidgold MacBook Pro 1 Jan 16, 2008 01:56 PM
HOW do i change the number sequence from us to uk/aus etc??? iCantwait Jailbreaks and iOS Hacks 4 Dec 8, 2007 02:11 AM
Is there ANY good reason to convert from AAC to Lossless. kavika411 iPod 6 Feb 9, 2007 12:50 PM
What lossy format for iPod? Best app to convert from ALAC to lossy? netdog iPod 3 May 28, 2006 12:11 PM
What lossy format for iPod? Best app to convert from ALAC to lossy? netdog Digital Audio 2 May 28, 2006 10:00 AM


All times are GMT -5. The time now is 03:03 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC