我想將我的經緯度傳遞給我的url參數,但返回零,但是當我在委託內打印時返回經度和緯度,我似乎無法找到問題,我已經嘗試了很多不同的方式和似乎沒有任何工作將CLLocationManager的經度和緯度傳遞給URL?
這是在哪裏存儲我的緯度和經度變量
var lat: Double! var long: Double!
這是我代表
func locationManager(_ manager:CLLocationManager, didUpdateLocations locations: [CLLocation]){
currentLocation = manager.location!.coordinate
let locValue:CLLocationCoordinate2D = currentLocation!
self.long = locValue.longitude
self.lat = locValue.latitude
print(lat)
print(long)
}
和她Ë他們傳遞給我用了我的URL參數變量,但他們回到零,我不明白爲什麼
let userLat = String(describing: lat)
let userLong = String(describing: long)
謝謝
確切位置在哪裏,你聲明''lat'and long'?你在哪裏試圖獲得他們的價值?你是否將委託分配給CLLocationManager實例? –
我的課後,我沒有分配它的委託在視圖沒有加載 – SCS