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

Summary

In this chapter, we covered everything that I consider a prerequisite for the rest of this book. We started with classes, the basic building blocks of OOP. You should now be really familiar with them. Structs are unusual constructions for someone coming from OOP, but they are very useful in Swift, as they behave as values, can be immutable, and have other nice properties. With enums, you'll be able to write even more expressive code.

Functions and closures are first-class citizens in Swift, and should be treated as such. Currying is a powerful pattern that lets you reuse functions; in later chapters, you'll see how to use it to write clean code.

The concept of protocols opens the world of protocol extensions and protocol-oriented programming, which is a complex subject. In the following chapters, we'll look at various use cases for implementing particular patterns through protocol extensions.

In the next chapter, we'll focus on memory management and ARC. While value types are not subject to reference counting, classes, functions, and closures interact with each other, and can lead to memory-related crashes and other issues.

主站蜘蛛池模板: 江山市| 通化市| 宜宾县| 和平县| 体育| 乡宁县| 莱芜市| 商城县| 西昌市| 略阳县| 巴彦淖尔市| 池州市| 宁夏| 浮山县| 合江县| 达日县| 龙山县| 沧州市| 梁平县| 张家港市| 丰台区| 祁连县| 上高县| 洪洞县| 冷水江市| 开封市| 泽州县| 三都| 宁南县| 南皮县| 渝中区| 雷波县| 南召县| 祁连县| 资源县| 交口县| 葫芦岛市| 蒙自县| 天峻县| 萝北县| 新安县|