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

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.

主站蜘蛛池模板: 蒲城县| 清徐县| 杭锦旗| 沈阳市| 滁州市| 德令哈市| 南投市| 鲁山县| 正安县| 新建县| 师宗县| 那坡县| 嘉善县| 会同县| 长寿区| 溧阳市| 龙州县| 兴隆县| 连州市| 梧州市| 炉霍县| 黑山县| 镇平县| 苗栗市| 桦川县| 汝州市| 桂东县| 山丹县| 巴东县| 祁阳县| 威海市| 仙桃市| 通榆县| 磐安县| 彰武县| 准格尔旗| 新建县| 新干县| 彭泽县| 南京市| 镇原县|