【发布时间】:2019-04-02 23:05:30
【问题描述】:
为 openweathermap 设置 API。但是,当涉及到设置时:
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations[0]
lat = location.coordinate.latitude
lon = location.coordinate.longitude
AF.request("http://api.openweathermaps.org/data/2.5/weather?lat=\(lat)&lon=\(lon)&appid=\(apiKey)&units=metric").responseJSON {
response in
self.activityIndicator.stopAnimating()
if let responseStr = response.result.value {
let jsonResponse = JSON(responseStr)
let jsonWeather = jsonResponse["weather"].array![0]
let jsonTemp = jsonResponse["main"]
let iconName = jsonWeather["icon"].stringValue
}
}
}
我得到错误:
“值”由于“内部”保护级别而无法访问
【问题讨论】:
-
我之前也遇到过这个问题,你试过把这个功能公开吗?
-
你是怎么做到的?