我有两个框架
First- Restofire 。它具有带有扩展功能的协议(protocol)ResponseSerializer。
public protocol ResponseSerializable {
/// The type of object returned in response.
associatedtype Model
/// The `Alamofire.ResponseSerializer`.
var responseSerializer: ResponseSerializer<Model, NSError> { get }
}
extension ResponseSerializable {
/// `CustomJSONResponseSerializer`
public var responseSerializer: ResponseSerializer<Model, NSError> {
return AlamofireUtils.JSONResponseSerializer()
}
}
Second- Restofire-Gloss 。它对Restofire框架中符合Decodable的模型的协议(protocol)进行了扩展。
public extension ResponseSerializable where Model: Decodable {
/// `GLOSSResponseSerializer`
public var responseSerializer: ResponseSerializer<Model, NSError> {
return GlossUtils.GLOSSResponseSerializer()
}
}
public extension ResponseSerializable where Model: CollectionType, Model.Generator.Element: Decodable {
/// `GLOSSResponseSerializer`
public var responseSerializer: ResponseSerializer<Model, NSError> {
return GlossUtils.GLOSSResponseSerializer()
}
}
当我将Restofire-Gloss的源文件直接导入到项目中时,一切都按预期工作,但是当我导入框架时,则控件未达到Restofire-Gloss框架中的功能。
最佳答案
也许您应该将扩展名标记为公开?
关于ios - 从另一个框架扩展Swift协议(protocol)时出现意外行为(Restofire),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36909673/