我正在学习iOS开发,我尝试从手机获取GPS信息并使用Alamofire发送到API,如下所示
let parameter = ["appVersion": "1.3.1",
"countryCode": "TZ",
"deviceName": "chrome",
"deviceId": "Web",
"deviceOS": "Mac OS",
"deviceToken": "token",
"latitude":"nothing",
"longitude":"nothing",
"date":"nothing",
"time":"nothing"
"speed":"Nothing"
]
AF.request("https://mtvmax.com/api/login",method: .post,parameters: parameter).response{
response in
debugPrint(response)
}
并通过手机获取GPS信息
func locationManager(_ _manager:CLLocationManager, didUpdateLocations Location:[CLLocation]){
if let location = Location.first{
//print(location.coordinate)
Uilabel.text = location.description
//print(location.description)
}
}
当我打印location.description
时,收到响应<+37.78583400,-122.40641700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 9/15/22, 10:05:21 AM East Africa Time
我的问题是如何操作这个字符串来获得纬度、经度、时间、日期、速度、航向和海拔的子字符串。我为我的英语正在使用谷歌翻译道歉
1条答案
按热度按时间rt4zxlrg1#
可以使用CLLocation类获取这些值,如下所示: