私は ReactiveSwift の初心者です。天気予報アプリを作成しましたが、リクエストが機能しません。
func fetchCurrentWeather() -> SignalProducer<TodayWeatherData?, DownloadError> {
guard let unwrappedURL = url else { return SignalProducer.empty }
return URLSession.shared.reactive
.data(with: URLRequest(url: unwrappedURL))
.retry(upTo: 2)
.flatMapError { error in
print("Error = \(error.localizedDescription)")
return SignalProducer.empty
}
.map { (data, response) -> TodayWeatherData? in
do {
let weatherArray = try JSONDecoder().decode(TodayWeatherData.self, from: data)
return weatherArray
} catch (let error) {
print("\(error)")
return nil
}
}
.observe(on: UIScheduler())
}
self.weatherFetcher.fetchCurrentWeather().map { weather in
}
マップ ブロックは呼び出されません。このリクエストまたは解析メソッドで何を変更する必要がありますか?