swift5 使用未声明的类型 'CLLocaitonDegress'
swift5 Use of undeclared type 'CLLocaitonDegress'
我试图从我的应用程序中获取纬度和经度的值。
但是“使用未声明的类型'CLLocaitonDegress'”这个消息有一些错误..
我不明白我的代码发生了什么??
func fetchWeather(latitude: CLLocaitonDegress, longitude: CLLocationDegrees) {
let urlString = "\(weatherURL)&lat=\(latitude)&lon=\(longitude)"
performRequest(urlString: urlString)
}
//MARK: -CLLocationManagerDelegate
extension WeatherViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.last {
let lat: Double = location.coordinate.latitude
let lon: Double = location.coordinate.longitude
weatherManager.fetchWeather(cityName: String, latitude: lat, longitude: lon)
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("error")
}
}
您需要在 import UIKit 下添加 import CoreLocation
import UIKit
import CoreLocation
在你的代码中替换:
func fetchWeather(纬度:CLLocaitonDegress,经度:CLLocationDegrees)
有了这个:
func fetchWeather(纬度:CLLocationDegrees,经度:CLLocationDegrees)
我试图从我的应用程序中获取纬度和经度的值。 但是“使用未声明的类型'CLLocaitonDegress'”这个消息有一些错误.. 我不明白我的代码发生了什么??
func fetchWeather(latitude: CLLocaitonDegress, longitude: CLLocationDegrees) {
let urlString = "\(weatherURL)&lat=\(latitude)&lon=\(longitude)"
performRequest(urlString: urlString)
}
//MARK: -CLLocationManagerDelegate
extension WeatherViewController: CLLocationManagerDelegate {
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
if let location = locations.last {
let lat: Double = location.coordinate.latitude
let lon: Double = location.coordinate.longitude
weatherManager.fetchWeather(cityName: String, latitude: lat, longitude: lon)
}
}
func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) {
print("error")
}
}
您需要在 import UIKit 下添加 import CoreLocation
import UIKit
import CoreLocation
在你的代码中替换: func fetchWeather(纬度:CLLocaitonDegress,经度:CLLocationDegrees)
有了这个:
func fetchWeather(纬度:CLLocationDegrees,经度:CLLocationDegrees)