Monday, July 20, 2026
HomeiOS Developmentios - Swift 5: Generic parameter 'Failure' and 'Success 'couldn't be inferred...

ios – Swift 5: Generic parameter ‘Failure’ and ‘Success ‘couldn’t be inferred with Outcome Kind

[ad_1]

Im attempting to make use of Outcome Kind in my service, however i obtain this error “Generic parameter ‘Failure’ and ‘Success ‘couldn’t be inferred” within the .map{response in } line.

Then I strive to do that .map { response -> Outcome<TimeDepositMutation, ErrorMutation> in, however i obtain a unique error within the .failure() line:
Can not convert return expression of kind ‘()’ to return kind ‘Outcome<Mutation, ErrorMessage>’

That is my code:

enum ErrorMessage: Error {
    case messageError
}

remaining class ServiceManager: Service {

    func getService() -> Observable<Outcome<Mutation, ErrorMessage>> {
        
        let physique = ["query": "mutation (mutationQuery)"]
        
        return Observable.create { observer in
            _ = self.graphQL(physique: physique)
                .map{ strive JSONDecoder().decode(ResponseData.self, from: $0) }
                .map { response  -> Lead to // error right here
                    
                    guard response.knowledge != nil else {
                        return observer.onNext(.failure(.messageError))
                    }
                    observer.onNext(.success((response.knowledge?.mutation)!))
                }
            return Disposables.create()
        }
    }
}

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments