Generic type 'Result' specialized with too many type parameters (got 2, but expected 1)
Asked Answered
B

1

11

My code and the error

how would I solve this error and it only appears when I import Almofire.

Bleier answered 26/5, 2019 at 22:36 Comment(1)
Please post code and error as text.Protection
M
40

It's Swift.Result<T, Error>, not Swift.Result<T1, T2>. If you want to pass two values, use a tuple, i.e. Swift.Result<([Character], Data), Error> (the tuple can be auto-expanded in a switch/case handling of the result)

Also, Alamofire defines it's own Result<T> type. You should prefix it with Swift. if you want to use the Swift 5 type.

Moral answered 26/5, 2019 at 22:42 Comment(7)
Thank you this is my first time using AlamofireBleier
In my case was a conflict with Alamofire, just prefixing the issue was solved. Many Thanks.Antiphonal
We can probably remove the first part of the answer. It is actually Swift.Result<Success,Failure> where Failure: Error. The real problem here is that Alamofire has it defined differently (which you mention later). The first part is confusing and incorrectFranglais
And Success is T. You're nit-picking, nothing is incorrect, and anyone who would find it confusing already knows how generics in Swift works. Besides, Alamofire replaced their internal type with the Swift 5 around the same time this answer was written We might as well delete the question. Yet it keep getting upvotes, so I'm guessing people still hit this problem with older versions of Alamofire.Tees
@DanielGalasko it also begs the question, why are you here commenting on a over 2 year old answer? Surely there's better things to do on Stack Overflow, like answering questions :pTees
@ClausJørgensen my country is still in lockdown so I beg to differ :-D In all seriousness though I genuinely had the same error come up and forgot that Alamofire has their own result type 🙄Your answer helped me so thank youFranglais
In my case, there are three different sources for Result<>, * Swift.Result<> * Auth0.Result<> * Guardian.Result<>Diahann

© 2022 - 2024 — McMap. All rights reserved.