阅读背景:

为什么协议在swift中比class好?

来源:互联网 

By watching the video tutorial provided by Apple, it seems that swift is protocol-oriented programming langue and apple encourage programmers to use protocol than class. But from my personal view, I see no apparent advantages for protocol. class can conform to protocol, but they can also inherit from superclass. We can add extension to protocol, but we can also add extension to class. We can implement functions in classes which conforms to protocol, but we can also override func in subclass. I am still confused that why we need to use protocol rather than class. And when we should use protocol instead of class ?By watching the video tutorial provided by Appl




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: