首页 > 解决方案 > 有没有办法改变 Xcode 的协议一致性自动完成行为

问题描述

可以说我有协议:

protocol FooProtocol{
    func bar<Request: Codable, Response: Codable>()
}

我有课:

class Foo: FooProtocol { //Xcode complains here about protocol conformance with a fix button
}

如果我点击 Xcode 自动完成来修复协议一致性,则会生成以下函数:

class Foo: FooProtocol {
    func bar<Request, Response>() where Request : Decodable, Request : Encodable, Response : Decodable, Response : Encodable {

    }
}

不是很漂亮。我必须手动重写函数:

func bar<Request: Codable, Response: Codable>()

有没有办法在 Xcode 中改变这种行为?

标签: xcode

解决方案


不,所有标准库也都以这种令人发指的方式格式化。

struct Dictionary<Key, Value> where Key : Hashable {

推荐阅读