Protocol kann nur als allgemeine Einschränkung verwendet werden, da es Self- oder AssociatedType-Anforderungen hat.
Ich habe ein RequestType-Protokoll und das dazugehörige Type-Modell (siehe unten).
public protocol RequestType: class {
associatedtype Model
var path: String { get set }
}
public extension RequestType {
public func executeRequest(completionHandler: Result<Model, NSError> -> Void) {
request.response(rootKeyPath: rootKeyPath) { [weak self] (response: Response<Model, NSError>) -> Void in
completionHandler(response.result)
guard let weakSelf = self else { return }
if weakSelf.logging { debugPrint(response) }
}
}
}
Jetzt versuche ich, alle fehlgeschlagenen Anfragen in eine Warteschlange zu stellen.
public class RequestEventuallyQueue {
static let requestEventuallyQueue = RequestEventuallyQueue()
let queue = [RequestType]()
}
Aber ich bekomme den Fehler in der Zeilelet queue = [RequestType]()
Das Protokoll RequestType kann nur als allgemeine Einschränkung verwendet werden, da es Self- oder AssociatedType-Anforderungen hat.