I am trying to create an app that will find the sunrise time and I am using this web API that requires both coordinates of the location.
This is my solution for to get the latitude and longitude but then it does not let me store the coordinates in the variables.(The coordinates must be float)
Why doesn't it let me put those numbers inside the variables ? or is there a better way of implementing this?
let lattitude: Float = 0.0000
let longitude: Float = 0.0000
let address = "Tokyo"
CLGeocoder().geocodeAddressString(address) { placemarks, error in
if let lat = placemarks?.first?.location?.coordinate.latitude{
print("lattitude : \(lat)")
lattitude = lat
}
if let lng = placemarks?.first?.location?.coordinate.longitude{
print("longtitude : \(lng)")
longtitude = lng
}
}