Need help with threads

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
    }

Would you clarify what specifically you are referring to here? Is there anything that prevents you from making this function async or using callbacks?

It does not seem to fit in any category, does it?

"Using Swift" category seems most appropriate here.

Regardless, your getCurrentWeather function is asynchronous and non-blocking, while loadDataStaticCell is synchronous. You need to reconcile this somehow by using one of the two established approaches: either make both getCurrentWeather and loadDataStaticCell async, or add a callback argument to loadDataStaticCell to make them consistent with each other.

There is a third "hybrid" solutions that involves continuations, in case you can't modify getCurrentWeather, but still want loadDataStaticCell to be async. (Assuming you can use Swift 5.5 and can deploy to OS versions that support Swift concurrency).