ios – withUnsafeThrowingContinuation Type of expression is ambiguous without more context


**
I m trying to use make @escaping function to async/await with withUnsafeThrowingContinuation, but there is error Type of expression is ambiguous without more context**

private func asyncUpload() async {
        guard let image = self.manager?.getUserModel()?.image else { return }
        let body = SetAvatarRequest(username: UserManager.shared.username, image: image)
        do {
            try await withUnsafeThrowingContinuation { (continuation: UnsafeContinuation<Void, Error>) in
                RESTClient.shared.uploadImage(
                    fileName: "\(UserManager.shared.username)_avatar",
                    path: "files/avatar/\(UserManager.shared.userId)",
                    body: body) { result in
                        print(result)
                        switch result {
                        case .success:
                            UserManager.shared.setImage(image)
                     continuation.resume(returning: ())
                            self?.removeFromFailed(type: type)
                        case let .failure(error):
                            print("DEBUG: \(error.localizedDescription)")
                 continuation.resume(throwing: error)
                        }
                    }
            } as Void
        } catch {
            print("error")
        }
    }```

Latest articles

spot_imgspot_img

Related articles

Leave a reply

Please enter your comment!
Please enter your name here

spot_imgspot_img