Log In
Or create an account -> 
Imperial Library
  • Home
  • About
  • News
  • Upload
  • Forum
  • Help
  • Login/SignUp

Index
Title Page
Fourth Edition
Copyright
Mastering Swift 4
Fourth Edition
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
Taking the First Steps with Swift
What is Swift?
Swift features
Playgrounds
Getting started with Playgrounds iOS, tvOS, and macOS Playgrounds Showing images in a Playground Creating and displaying graphs in Playgrounds What Playgrounds are not Swift language syntax Comments Semicolons Parentheses Curly brackets An assignment operator does not return a value Spaces are optional in conditional and assignment statements
Hello World Summary
Learning about Variables, Constants, Strings, and Operators
Constants and variables
Defining constants and variables Type safety Type inference Explicit types Numeric types
Integer types Floating-point and Double values
The Boolean type The string type Optional variables Optional binding Optional chaining Enumerations
Operators
The assignment operator Comparison operators Arithmetic operators The remainder operator Compound assignment operators The ternary conditional operator The logical NOT operator The logical AND operator The logical OR operator
Summary
Using Swift Collections and the Tuple Type
Swift collection types Mutability Arrays
Creating and initializing arrays Accessing the array elements Counting the elements of an array Is the array empty? Appending to an array Inserting a value into an array Replacing elements in an array Removing elements from an array Merging two arrays Retrieving a subarray from an array Making bulk changes to an array Algorithms for arrays
Sort Sorted Filter Map forEach
Iterating over an array
Dictionaries
Creating and initializing dictionaries Accessing dictionary values Counting the key or values in a dictionary Is the dictionary empty? Updating the value of a key Adding a key-value pair Removing a key-value pair
Set
Initializing a set Inserting items into a set Determining the number of items in a set Checking whether a set contains an item Iterating over a set Removing items in a set Set operations
Tuples Summary
Control Flow and Functions
What have we learned so far?
Curly brackets Parentheses
Control flow
Conditional statements
The if statement Conditional code execution with the if...else statement The guard statement
The for-in loop
Using the for...in loop
The while loop
Using the while loop Using the repeat-while loop
The switch statement Using case and where statements with conditional statements
Filtering with the where statement Filtering with the for-case statement Using the if-case statement
Control transfer statements
The continue statement The break statement The fallthrough statement
Functions
Using a single parameter function Using a multi-parameter function Defining a parameter's default values Returning multiple values from a function Returning optional values Adding external parameter names Using variadic parameters Inout parameters
Putting it all together Summary
Classes and Structures
What are classes and structures?
Similarities between classes and structures Differences between classes and structures Value versus reference types
Creating a class or structure
Properties Stored properties Computed properties Property observers Methods
Custom initializers
Internal and external parameter names Failable initializers
Access controls Inheritance Overriding methods and properties
Overriding methods Overriding properties Preventing overrides
Protocols Protocol syntax
Property requirements Method requirements
Extensions Memory management
How ARC works Strong reference cycles
Summary
Using Protocols and Protocol Extensions
Protocols as types Polymorphism with protocols Type casting with protocols Protocol extensions Do I need to use protocols? Swift's standard library Summary
Protocol-Oriented Design
Requirements Object-oriented design
Protocol-oriented design Protocol inheritance Protocol composition Protocol-oriented design Using the where statement with protocols
Structures versus classes The array structure Summary
Writing Safer Code with Availability and Error Handling
Native error handling
Representing errors Throwing errors Catching errors
The availability attribute Summary
Custom Subscripting
Introducing subscripts Subscripts with Swift arrays Creating and using custom subscripts Read-only custom subscripts Calculated subscripts Subscript values External names for subscripts Multidimensional subscripts When not to use a custom subscript Summary
Using Optional Types
Introducing optionals The need for optional types in Swift
Defining an optional Using optionals
Forced unwrapping of an optional Optional binding Returning optionals from functions and methods Using an optional as a parameter in a function or method Optional binding with the guard statement Optional types with tuples
Optional chaining
The nil coalescing operator
Summary
Working with Generics
An introduction to generics Generic functions Generic types Generic subscripts Associated types Summary
Working with Closures
An introduction to closures Simple closures Shorthand syntax for closures Using closures with Swift's array algorithms Standalone closures and good style guidelines Changing functionality Selecting a closure based on results Creating strong reference cycles with closures Summary
Using Mix and Match
What is mix and match? When to use mix and match Using Swift and Objective-C together in the same project
Creating the project Adding Swift files to the Objective-C project The Objective-C bridging header file - part 1 Adding the Objective-C file to the project The Messages Objective-C class The Objective-C bridging header file - part 2 The MessageBuilder Swift class - accessing Objective-C code from Swift The Objective-C class - accessing Swift code from Objective-C
Summary
Concurrency and Parallelism in Swift
Concurrency and parallelism
Grand Central Dispatch Calculation type
Creating queues
Creating and using a concurrent queue Creating and using a serial queue
async versus sync Executing code on the main queue function Using asyncAfter
Using the Operation and OperationQueue types
Using BlockOperation Using the addOperation() method of the operation queue Subclassing the Operation class
Summary
Swift Formatting and Style Guide
What is a programming style guide? Your style guide
Do not use semicolons at the end of statements Do not use parentheses for conditional statements Naming
Custom types Functions and methods Constants and variables Indenting
Comments Using the self keyword Constants and variables Optional types
Using optional binding Using optional chaining instead of optional binding for multiple unwrapping
Using type inference Using shorthand declaration for collections Using switch rather than multiple if statements Don't leave commented-out code in your application
Summary
Swift Core Libraries
Apple's URL loading system
URLSession URLSessionConfiguration URLSessionTask URL URLRequest HTTPURLResponse REST web services Making an HTTP GET Request Making an HTTP POST request
Formatter
DateFormatter NumberFormatter FileManager
Encoding and Decoding JSON Data
Using JSONEncoder Using JSONDecoder
Summary
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
Understanding the problem Understanding the solution Implementing the builder pattern
Structural design patterns
The bridge pattern
Understanding the problem Understanding the solution Implementing the bridge pattern
The façade pattern
Understanding the problem Understanding the solution Implementing the façade pattern
The proxy design pattern
Understanding the problem Understanding the solution Implementing the proxy pattern
Behavioral design patterns
The command design pattern
Understanding the problem Understanding the solution Implementing the command pattern
The strategy pattern
Understanding the problem Understanding the solution Implementing the strategy pattern
Summary
  • ← Prev
  • Back
  • Next →
  • ← Prev
  • Back
  • Next →

Chief Librarian: Las Zenow <zenow@riseup.net>
Fork the source code from gitlab
.

This is a mirror of the Tor onion service:
http://kx5thpx2olielkihfyo4jgjqfb7zx7wxr3sd4xzt26ochei4m6f7tayd.onion