Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert string to CLLocationCoordinate

Tags:

xcode

ios

swift

Is it possible to convert a string to a longitude/latitude value? I managed to convert the coordinate to a string, but I cannot find a way to revert the process

like image 394
Pierre Olivier Tran Avatar asked Nov 29 '22 01:11

Pierre Olivier Tran


2 Answers

Another way to convert:

let latitude = (latitudeString as NSString).doubleValue
let longitude = (longitudeString as NSString).doubleValue
like image 154
sanjana Avatar answered Dec 12 '22 02:12

sanjana


Swift 3

let lat = Double(String1)
let lon = Double(String2)

 let coordinates = CLLocationCoordinate2D(latitude:lat!
                        , longitude:lon!)

CLLocationCoordinate2D is a double value it can convert string into double See in above example

like image 44
kiran pm Avatar answered Dec 12 '22 03:12

kiran pm