0

我有以下简单的协议:

protocol JSONParser {

   associatedtype JSONResult
   func parse<T: Codable>(response: Response, type: T) -> JSONResult

}

函数parse采用 simple Responsewhich is struct 并采用Twhich is Codable。以下是我实现此协议的方式:

struct AuthJSONParser: JSONParser {

    func parse<T: Codable>(response: Response, type: T) -> AuthResult<T> {

    }

}

似乎一切都好。但是 Xcode 说它不符合协议。这里AuthResult<T>只是为了案例:

enum AuthResult<Model: Codable> {
   case success(data: Model)
   case failed(msg: String)
}

我无法弄清楚我的实施有什么问题。我想使用泛型函数,而不是泛型结构。

4

0 回答 0