I'm having a function like this:
func someFunction<T: Codable>(x: Double, y: Double, outputClass: T, completionBlock: CompletionBlock)
the completionblock is:
enum Result {
case success(Codable)
case failure(String?)
}
typealias CompletionBlock = (Result) -> Void
What I want to achieve is that when you call the function for example like this:
someFunction(x: 12, y: 12, outputClass: Foo.self) { (result) in
switch result {
case .success(let result):
}
That my let result in the success case is of type Foo.
I have a Foo struct:
struct Foo: Codable {
let content: String
}
Now when I try to call the function xCode tells me:
Argument type 'Foo.Type' does not conform to expected type 'Encodable'
But the struct conforms to the type Codable and that is encodable & decodable.
Can someone explain me what I'm doing wrong?
Codable. - Paulw11