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

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.

主站蜘蛛池模板: 福清市| 景德镇市| 洱源县| 辽中县| 二连浩特市| 宜君县| 温宿县| 长垣县| 九台市| 松滋市| 承德县| 龙泉市| 精河县| 武义县| 分宜县| 丁青县| 浪卡子县| 汝城县| 新丰县| 和静县| 都匀市| 灵川县| 常州市| 新宁县| 祁阳县| 阿鲁科尔沁旗| 彩票| 新津县| 南涧| 崇明县| 沿河| 眉山市| 阜平县| 蚌埠市| 郴州市| 祁东县| 尼木县| 长武县| 重庆市| 岳池县| 罗田县|