更新时间:2021-07-02 14:46:05
coverpage
Title Page
Copyright and Credits
Hands-On Design Patterns with Swift
About Packt
Why subscribe?
Packt.com
Contributors
About the authors
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Refreshing the Basics
Classes and structs
Classes
Struct
Enums
Simple enums
Adding methods
Associating values
Generic enums
Raw type enums
Switching the state of light
Closures functions and currying
Currying
Using closures as callbacks
Using weak and unowned
Protocols
Declaring a protocol
Conforming to a protocol
Conformance at declaration
Conformance in an extension
Protocol extensions
Default implementations
Tuples type aliases and generics
Tuples
Declaring tuples
Destructuring tuples
Using tuples in functions
Type aliases
Generics
Generic functions
Generic types
Generics protocols and associated types
Summary
Understanding ARC and Memory Management
A brief history of reference counting
The semantics of reference counting
Retain
Release
Assign
Copying
Using and misusing manual reference counting
Memory leaks
Dangling pointers
ARC – what is that?
Value types
Strong references
Weak references
Unowned references
Memory debugging
Configuring your project
Using the memory graph hierarchy tool
Leaks cycles and dangling references
Leaking with cycles
A simple leak
Fixing the leak
Using weak
Using unowned
Dangling references
Diving into Foundation and the Standard Library
Swift basic types
Working with ranges
Range as Sequence
Throwing and catching errors
Container types
Arrays
Mutability and operations
Iterating mapping and reducing
Dictionaries
Initialization and mutability
Mastering concurrency with Dispatch
Tasks and queues
Synchronization with Dispatch
Thread safety through serial queues
Organizing execution with groups and semaphores
Example of a counting semaphore
Using groups
HTTP with URLSession
Making your first call with URLSession