Rakesh Mohan Rakesh Mohan - 2 months ago 13
iOS Question

How to convert Latitude and longitude to float value in swift

I have tried the below code :
but it shows error cannot convert value of type float to expected argument type CLLocation degrees(aka Double)

let lat = self.mallData.valueForKey("lat") as! Float
let lon = self.mallData.valueForKey("lon")



let mapLocation : CLLocationCoordinate2D = CLLocationCoordinate2DMake(lat, lon)

Answer

The CLLocationCoordinate2DMake supports Double values. But you are converting lat and lon to Float.

Try converting Lat and Lon to Double.

Comments