更新时间:2021-07-08 09:42:58
coverpage
Title Page
Third Edition
Copyright
Swift 4 Protocol-Oriented Programming
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Starting with the Protocol
Protocol syntax
Defining a protocol
Property requirements
Method requirements
Optional requirements
Protocol inheritance
Protocol composition
Using protocols as a type
Polymorphism with protocols
Type casting with protocols
Associated types with protocols
Delegation
Designing with protocols
Protocols in the Swift standard library
Summary
Our Type Choices
Classes
Structures
Access controls
Enumerations
Tuples
Protocols
Value and reference types
Recursive data types for reference types only
Inheritance for reference types only
Dynamic dispatch
Swift's built-in types
Copy-on-write
Extensions
Defining an extension
Protocol extensions
Text validation
Extensions with the Swift standard library
Conforming to the Equatable protocol
Generics
Generic functions
Type constraints with Generics
Generic types
Associated types
Generic subscripts
Generics in a protocol-oriented design
Generics in the Swift standard library
Object-Oriented Programming
What is object-oriented programming?
Requirements for the sample code
Swift as an object-oriented programming language
Issues with the object-oriented design
Protocol-Oriented Programming
Swift as a protocol-oriented programming language
Summarizing protocol-oriented programming and object-oriented programming
Differences between object-oriented programming and protocol-oriented programming
Protocol and protocol extensions compared with superclasses
Implementing vehicle types
Using value and reference types
The winner is...
Adopting Design Patterns in Swift
What are design patterns?
Creational patterns
The singleton design pattern
Understanding the problem
Understanding the solution
Implementing the singleton pattern
The builder design pattern
Implementing the builder pattern
The factory method pattern