官术网_书友最值得收藏!

Summary

While protocols themselves may not seem very exciting, they are actually quite powerful. As we saw in this chapter, we are able to use them to create very specific requirements. We can then use protocol inheritance and protocol composition to create protocol hierarchies. We also saw how to implement the delegation patterns with protocols.

We concluded the chapter by showing how we can model a robot with sensors using the protocol and how Apple uses protocols in the Swift standard library.

In Chapter 3, Extensions, we will see how we can use protocol extensions to add functionality to types that conform to a protocol but before we do that, let's look at our type choices.

主站蜘蛛池模板: 侯马市| 内江市| 元江| 青川县| 阳谷县| 镇沅| 郧西县| 榆林市| 安溪县| 泸定县| 永善县| 洛南县| 金华市| 璧山县| 芜湖市| 星子县| 广安市| 外汇| 离岛区| 定日县| 综艺| 深泽县| 略阳县| 舟曲县| 班戈县| 荔波县| 富民县| 滕州市| 黑山县| 武平县| 平山县| 汝州市| 高唐县| 稻城县| 阿巴嘎旗| 吕梁市| 保靖县| 华容县| 北安市| 山阴县| 乐都县|