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

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.

主站蜘蛛池模板: 花莲县| 佛冈县| 巧家县| 甘泉县| 壶关县| 合水县| 和硕县| 承德市| 花莲县| 牡丹江市| 奉新县| 无棣县| 商城县| 太康县| 漳浦县| 罗平县| 贡嘎县| 隆林| 共和县| 宁强县| 曲周县| 临洮县| 凤冈县| 米易县| 乌海市| 永泰县| 博白县| 钦州市| 陈巴尔虎旗| 灌南县| 富川| 博罗县| 江源县| 麻阳| 安阳市| 阿拉尔市| 茂名市| 酒泉市| 安远县| 诸暨市| 开远市|