Hi, all.
The problem is clear, I the return is return before AIP call finishes work.
I cannot understand how to deal with the issue beautifully. Could you give me a hint?
func loadDataStaticCell() -> ResultStaticCell {
var staticCellWholeModel = ResultStaticCell.failure("Hell")
netWorkManager.getCurrentWeather(forCity: cityName) { [unowned self] result in
print(Thread.current)
switch result {
case let .success(success):
let cellModel = self.makeStaticCellModel(apiModel: success)
staticCellWholeModel = ResultStaticCell.success([cellModel])
case let .failure(text):
let failure = ResultStaticCell.failure(text)
staticCellWholeModel = failure
}
}
print(Thread.current)
return staticCellWholeModel
}