Advanced Swift

克里斯·安道夫Publishing House of Electronics Industry · ChinaOct 2020

Rating 4.2
Word count
183K words
Chapters
83
ISBN
9787121312007

Tags

Programming iOS DevelopmentCode AbstractionProtocol-OrientedArchitecture DesignGeneric ProgrammingSystems ProgrammingProgramming AdvancedApple EcosystemLanguage FeaturesDeveloper Reading

Summary

This book covers advanced topics in Swift programming. If you have already read Apple's The Swift Programming Language and want to explore more about the language, this book is for you! Swift is great for systems programming, yet it can also be used to write high-level code. In this book, we will examine high-level abstractions such as generics and protocols, and we will also delve into low-level topics such as wrapping C code and the internal implementation of strings. This book will help you further complete your knowledge system and take you from a beginner or intermediate level in Swift through to becoming an advanced Swift developer.

Editor's review

Advanced Swift is not a beginner's guide, but a deep technical work intended to help developers move from 'knowing how to use Swift' to 'mastering Swift.' The author, Chris Eidhof, one of the core contributors to the Swift community, systematically analyzes the design philosophy and advanced features of the Swift language through his deep understanding of its features and extensive practical experience.

The greatest value of this book lies in its path of exploring 'knowing why it is so.' It does not stop at the level of syntax and API usage, but delves into core concepts such as the Swift type system, generic programming, functional programming paradigms, protocols and value semantics, and memory management. By building a complete image processing library as a case study running throughout the book, readers can intuitively understand how to apply these abstract concepts to solve real problems and design efficient, safe, and elegant Swift code.

For developers who have already mastered the basics of Swift and hope to improve code quality and architecture design skills, this book provides a valuable thinking framework. It guides readers to think about why Swift is designed the way it is (for example, the trade-offs between value types and reference types, and the advantages of protocol-oriented programming), and how to use these features to build more robust and maintainable applications. The discussions in the book on 'protocol-oriented programming' and 'functional reactive programming' are especially helpful for developers to keep up with the best practices and trends of modern Swift development.

Overall, this is a 'hardcore' book that requires calm reading and hands-on practice. It may not immediately improve your development speed, but it will fundamentally reshape your understanding of Swift programming and is an important cornerstone on the path to becoming an advanced iOS/macOS developer.

Who it's for

A good fit for

Not a good fit for

Reading tips

  1. It is recommended to read alongside Xcode, and be sure to practice every code example and project in the book; understanding is far better than reading alone
  2. You can combine it with the official The Swift Programming Language documentation: one focuses on practice and depth, the other on standards and comprehensiveness
  3. Do not rush while reading. After each chapter, try to think about how to apply what you have learned to refactor or improve your current project

About the publisher

Publishing House of Electronics Industry China · Founded in 1982

The Publishing House of Electronics Industry is a comprehensive publisher distinguished by its focus on electronic information and related fields. Judging from the more than 3,000 titles in its catalogue, its publishing covers programming and design, artificial intelligence, computer science, finance and economics, photography, and social sciences, attending both to cutting-edge technology and to general readers. Representative titles include Factor Investing: Methods and Practice, x86 Assembly Language: From Real Mode to Protected Mode, The RISC-V Reader, Artificial Intelligence: Speech Recognition, Understanding and Practice, Phased Array Radar Technology, Radar Target Characteristics, and 100 Go Mistakes and How to Avoid Them, most of which centre on technical methods and engineering practice. Its authors include Shi Chuan, Li Zhong, Wang Xiaobo, David Patterson, Andrew Waterman, and Yu Zihao, among others from China and abroad. Owing to limited public information, no further publishing features are elaborated here.

Contents

  1. 版权信息
  2. 内容简介
  3. 译者序
  4. 第1章 介绍
  5. 1.1 本书所面向的读者
  6. 1.2 主题
  7. 1.3 术语
  8. 1.4 Swift风格指南
  9. 第2章 内建集合类型
  10. 2.1 数组
  11. 2.2 字典
  12. 2.3 Set
  13. 2.4 Range
  14. 第3章 集合类型协议
  15. 3.1 序列
  16. 3.2 集合类型
  17. 3.3 索引
  18. 3.4 切片
  19. 3.5 专门的集合类型
  20. 3.6 总结
  21. 第4章 可选值
  22. 4.1 哨岗值
  23. 4.2 通过枚举解决魔法数的问题
  24. 4.3 可选值概览
  25. 4.4 强制解包的时机
  26. 4.5 多灾多难的隐式可选值
  27. 4.6 总结
  28. 第5章 结构体和类
  29. 5.1 值类型
  30. 5.2 可变性
  31. 5.3 结构体
  32. 5.4 写时复制
  33. 5.5 闭包和可变性
  34. 5.6 内存
  35. 5.7 闭包和内存
  36. 5.8 闭包和内存
  37. 5.9 总结
  38. 第6章 函数
  39. 6.1 函数的灵活性
  40. 6.2 局部函数和变量捕获
  41. 6.3 函数作为代理
  42. 6.4 inout参数和可变方法
  43. 6.5 计算属性和下标
  44. 6.6 自动闭包
  45. 6.7 总结
  46. 第7章 字符串
  47. 7.1 不再固定宽度
  48. 7.2 字符串和集合
  49. 7.3 简单的正则表达式匹配器
  50. 7.4 ExpressibleByStringLiteral
  51. 7.5 String的内部结构
  52. 7.6 编码单元表示方式
  53. 7.7 CustomStringConvertible和CustomDebugStringConvertible
  54. 7.8 文本输出流
  55. 7.9 字符串性能
  56. 7.10 展望
  57. 第8章 错误处理
  58. 8.1 Result类型
  59. 8.2 抛出和捕获
  60. 8.3 带有类型的错误
  61. 8.4 将错误桥接到Objective-C
  62. 8.5 错误和函数参数
  63. 8.6 使用defer进行清理
  64. 8.7 错误和可选值
  65. 8.8 错误链
  66. 8.9 高阶函数和错误
  67. 8.10 总结
  68. 第9章 泛型
  69. 9.1 重载
  70. 9.2 对集合采用泛型操作
  71. 9.3 使用泛型进行代码设计
  72. 9.4 泛型的工作方式
  73. 9.5 总结
  74. 第10章 协议
  75. 10.1 面向协议编程
  76. 10.2 协议的两种类型
  77. 10.3 带有Self的协议
  78. 10.4 协议内幕
  79. 10.5 总结
  80. 第11章 互用性
  81. 11.1 实践:封装CommonMark
  82. 11.2 低层级类型概览
  83. 11.3 函数指针

FAQ

What is this book's Douban rating? According to checks, this book has received high praise on Douban Books, with a rating above 8.5 (the exact score may change over time). Readers generally believe its content is sufficiently deep and that it is a rare good book on the path to advancing in Swift, while also noting that it has a certain reading threshold.
What is the difference between this book and books such as The Swift Programming Language or iOS Programming? The core difference lies in positioning. Books such as The Swift Programming Language are usually more comprehensive, covering a wide range of knowledge from basics to applications; Advanced Swift, by contrast, focuses on 'advanced' topics, deeply exploring the language's core mechanisms and advanced features, and is suitable for raising the level and deepening understanding after some practice.
Which Swift version are the code examples in the book based on? Are they outdated now? This book is based on Swift 3. Although later versions of the Swift language have been updated, the core ideas and design patterns it discusses (such as protocol extensions, value semantics, and functional thinking) are stable and enduring. For newer syntax, readers can, on the basis of understanding the book's ideas, easily consult the official documentation for adaptation. The value of this book lies in teaching the 'way' rather than being tied to the details of the 'technique.'

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

About the author

克里斯·安道夫 Author

Chris Eidhof is a technical author writing on the Swift language and iOS development. Publicly available information about his nationality, dates of birth and death, and educational background is limited, and what can be confirmed centers mainly on his writing. One of his works is included in the collection, Swift Advanced, a book in the programming and design category aimed at developers who already have some grounding in Swift and wish to deepen their understanding of the language's mechanisms and engineering practice. The subject matter tends toward advanced technical content, combining language features with design thinking rather than listing introductory syntax; the presentation is concrete and close to real development scenarios, helping readers turn abstract concepts into code. For Chinese-language readers, such a work can serve as a supplement to basic tutorials, broadening their understanding of Swift expression and programming design.