jjzjj

ProtocolB

全部标签

swift - 为什么协议(protocol)中的 get-only 属性要求不能被符合的属性满足?

为什么下面的代码会产生错误?protocolProtocolA{varsomeProperty:ProtocolB{get}}protocolProtocolB{}classConformsToB:ProtocolB{}classSomeClass:ProtocolA{//Type'SomeClass'doesnotconformtoprotocol'ProtocolA'varsomeProperty:ConformsToBinit(someProperty:ConformsToB){self.someProperty=someProperty}}Theanswerinthissimi

swift - 为什么协议(protocol)中的 get-only 属性要求不能被符合的属性满足?

为什么下面的代码会产生错误?protocolProtocolA{varsomeProperty:ProtocolB{get}}protocolProtocolB{}classConformsToB:ProtocolB{}classSomeClass:ProtocolA{//Type'SomeClass'doesnotconformtoprotocol'ProtocolA'varsomeProperty:ConformsToBinit(someProperty:ConformsToB){self.someProperty=someProperty}}Theanswerinthissimi