的通用协议性能要求挣扎了一会儿有,这将是非常有益的,如果你可以在此提供一些线索:如何声明在协议
我有一个APIWorkerProtocol
具有性能要求,所需财产是一个协议,即DataParserProtocol
protocol APIWorkerProtocol {
var apiRequestProvider : APIRequestGeneratorProtocol {get}
var dataParser : DataParserProtocol{get}
func callAPI(completionHandler: @escaping (APICallResult<Self.ResultType>) -> Void)
}
protocol DataParserProtocol {
associatedtype ExpectedRawDataType
associatedtype ResultType
func parseFetchedData(fetchedData : ExpectedRawDataType) -> APICallResult<ResultType>
}
我该怎么做到这一点?
在当前的实施中,这会导致错误Protocol 'DataParserProtocol' can only be used as a generic constraint because it has Self or associated type requirements
。
预先感谢
ANKIT
你是绝对正确我的@dfri –