iOS 14 Programming Fundamentals with Swift: Swift, Xcode, and Cocoa Basics

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Move into iOS development by getting a firm grasp of its fundamentals, including the Xcode 12 IDE, Cocoa Touch, and the latest version of Apple’s acclaimed programming language, Swift 5.3. With this thoroughly updated guide, you’ll learn the Swift language, understand Apple’s Xcode development tools, and discover the Cocoa framework. • Become familiar with built-in Swift types • Dive deep into Swift objects, protocols, and generics • Tour the life cycle of an Xcode project • Learn how nibs are loaded • Understand Cocoa’s event-driven design • Communicate with C and Objective-C In this edition, catch up on the latest iOS programming features: • Multiple trailing closures • Code editor document tabs • New Simulator features • Resources in Swift packages • Logging and testing improvements • And more! Once you master the fundamentals, you’ll be ready to tackle the details of iOS app development with author Matt Neuburg’s companion guide, Programming iOS 14.

Author(s): Matt Neuburg
Edition: 1
Publisher: O'Reilly Media
Year: 2020

Language: English
Commentary: Vector PDF
Pages: 708
City: Sebastopol, CA
Tags: Apple; iOS; Swift; Memory Management; Object-Oriented Programming; Xcode; Cocoa Framework; Elementary

Cover
Copyright
Table of Contents
Preface
The Scope of This Book
From the Preface to the First Edition (Programming iOS 4)
Versions
Acknowledgments
Conventions Used in This Book
Using Code Examples
O’Reilly Online Learning
How to Contact Us
Part I. Language
Chapter 1. The Architecture of Swift
Ground of Being
Everything Is an Object?
Three Flavors of Object Type
Variables
Functions
The Structure of a Swift File
Scope and Lifetime
Object Members
Namespaces
Modules
Instances
Why Instances?
The Keyword self
Privacy
Design
Chapter 2. Functions
Function Parameters and Return Value
Void Return Type and Parameters
Function Signature
External Parameter Names
Overloading
Default Parameter Values
Variadic Parameters
Ignored Parameters
Modifiable Parameters
Calling Objective-C with Modifiable Parameters
Called by Objective-C with Modifiable Parameters
Reference Type Modifiable Parameters
Function in Function
Recursion
Function as Value
Anonymous Functions
Using Anonymous Functions Inline
Anonymous Function Abbreviated Syntax
Define-and-Call
Closures
How Closures Improve Code
Function Returning Function
Closure Setting a Captured Variable
Closure Preserving Captured Environment
Escaping Closures
Curried Functions
Function References and Selectors
Function Reference Scope
Selectors
Chapter 3. Variables and Simple Types
Variable Scope and Lifetime
Variable Declaration
Computed Variable Initialization
Computed Variables
Computed Properties
Property Wrappers
Setter Observers
Lazy Initialization
Singleton
Lazy Initialization of Instance Properties
Built-In Simple Types
Bool
Numbers
String
Character and String Index
Range
Tuple
Optional
Chapter 4. Object Types
Object Type Declarations and Features
Initializers
Properties
Methods
Subscripts
Nested Object Types
Enums
Raw Values
Associated Values
Enum Case Iteration
Enum Initializers
Enum Properties
Enum Methods
Why Enums?
Structs
Struct Initializers
Struct Properties
Struct Methods
Struct as Namespace
Classes
Value Types and Reference Types
Subclass and Superclass
Class Initializers
Class Deinitializer
Class Properties
Static/Class Members
Polymorphism
Casting
Casting Down
Type Testing and Casting Down Safely
Type Testing and Casting Optionals
Bridging to Objective-C
Type References
From Instance to Type
From self to Type
Type as Value
Summary of Type Terminology
Comparing Types
Protocols
Why Protocols?
Adopting a Library Protocol
Protocol Type Testing and Casting
Declaring a Protocol
Protocol Composition
Class Protocols
Optional Protocol Members
Implicitly Required Initializers
Expressible by Literal
Generics
Generic Declarations
Contradictory Resolution Is Impossible
Type Constraints
Explicit Specialization
Generic Invariance
Associated Type Chains
Where Clauses
Extensions
Extending Protocols
Extending Generics
Umbrella Types
Any
AnyObject
AnyClass
Collection Types
Array
Dictionary
Set
Chapter 5. Flow Control and More
Flow Control
Branching
Loops
Jumping
Privacy
Private and Fileprivate
Public and Open
Privacy Rules
Introspection
Operators
Memory Management
Memory Management of Reference Types
Exclusive Access to Value Types
Miscellaneous Swift Language Features
Synthesized Protocol Implementations
Key Paths
Instance as Function
Dynamic Membership
Property Wrappers
Custom String Interpolation
Reverse Generics
Function Builders
Result
Part II. IDE
Chapter 6. Anatomy of an Xcode Project
New Project
The Project Window
The Navigator Pane
The Inspectors Pane
The Editor
Project File and Dependents
Contents of the Project Folder
Groups
The Target
Build Phases
Build Settings
Configurations
Schemes and Destinations
From Project to Built App
Build Settings
Property List Settings
Nib Files
Resources
Code Files
Frameworks, SDKs, and Packages
The App Launch Process
The Entry Point
How an App Gets Going
App Without a Storyboard
Renaming Parts of a Project
Chapter 7. Nib Files
The Nib Editor Interface
Document Outline
Canvas
Inspectors
Loading a Nib
Loading a View Controller Nib
Loading a Main View Nib
Loading a View Nib Manually
Connections
Outlets
The Nib Owner
Automatically Configured Nibs
Misconfigured Outlets
Deleting an Outlet
More Ways to Create Outlets
Outlet Collections
Action Connections
More Ways to Create Actions
Misconfigured Actions
Connections Between Nibs — Not!
Additional Configuration of Nib-Based Instances
Chapter 8. Documentation
The Documentation Window
Class Documentation Pages
Quick Help
Symbol Declarations
Header Files
Sample Code
Internet Resources
Chapter 9. Life Cycle of a Project
Environmental Dependencies
Conditional Compilation
Build Action
Permissible Runtime Environment
Backward Compatibility
Device Type
Arguments and Environment Variables
Version Control
Editing and Navigating Your Code
Text Editing Preferences
Multiple Selection
Autocompletion and Placeholders
Snippets
Refactoring and Structure Editing
Fix-it and Live Syntax Checking
Navigation
Finding
Running in the Simulator
Debugging
Caveman Debugging
The Xcode Debugger
Testing
Unit Tests
Interface Tests
Test Plans
Massaging the Report
Clean
Running on a Device
Obtaining a Developer Program Membership
Signing an App
Automatic Signing
Manual Signing
Running the App
Managing Development Certificates and Devices
Profiling
Gauges
Memory Debugging
Instruments
Localization
Creating Localized Content
Testing Localization
Distribution
Making an Archive
The Distribution Certificate
The Distribution Profile
Distribution for Testing
Final App Preparations
Screenshots and Video Previews
Property List Settings
Submission to the App Store
Part III. Cocoa
Chapter 10. Cocoa Classes
Subclassing
Categories and Extensions
How Swift Uses Extensions
How You Use Extensions
How Cocoa Uses Categories
Protocols
Optional Members
Informal Protocols
Some Foundation Classes
NSRange
NSNotFound
NSString and Friends
NSDate and Friends
NSNumber
NSValue
NSData
NSMeasurement and Friends
Equality, Hashability, and Comparison
NSArray and NSMutableArray
NSDictionary and NSMutableDictionary
NSSet and Friends
NSIndexSet
NSNull
Immutable and Mutable
Property Lists
Codable
Accessors, Properties, and Key–Value Coding
Swift Accessors
Key–Value Coding
How Outlets Work
Cocoa Key Paths
Uses of Key–Value Coding
KeyPath Notation
The Secret Life of NSObject
Chapter 11. Cocoa Events
Reasons for Events
Subclassing
Notifications
Receiving a Notification
Unregistering
Posting a Notification
Timer
Delegation
Cocoa Delegation
Implementing Delegation
Data Sources
Actions
The Responder Chain
Nil-Targeted Actions
Key–Value Observing
Registration and Notification
Unregistering
Key–Value Observing Example
Swamped by Events
Delayed Performance
Chapter 12. Memory Management
Principles of Cocoa Memory Management
Rules of Cocoa Memory Management
What ARC Is and What It Does
How Cocoa Objects Manage Memory
Autorelease Pool
Memory Management of Instance Properties
Retain Cycles and Weak References
Unusual Memory Management Situations
Notification Observers
KVO Observers
Timers
Other Unusual Situations
Nib Loading and Memory Management
Memory Management of CFTypeRefs
Property Memory Management Policies
Debugging Memory Management Mistakes
Chapter 13. Communication Between Objects
Visibility Through an Instance Property
Visibility by Instantiation
Getting a Reference
Visibility by Relationship
Global Visibility
Notifications and Key–Value Observing
The Combine Framework
Alternative Architectures
Model–View–Controller
Router and Data Space
Model–View–Presenter
Protocols and Reactive Programming
VIPER
SwiftUI
Function Builders and Modifiers
State Properties
Bindings
Passing Data Downhill
Passing Data Uphill
Custom State Objects
Appendix A. C, Objective-C, and Swift
The C Language
C Data Types
C Enums
C Structs
C Pointers
C Arrays
C Strings
C Functions
Objective-C
Objective-C Objects and C Pointers
Objective-C Objects and Swift Objects
Exposure of Swift to Objective-C
Bridged Types and Boxed Types
Objective-C Methods
Selectors
CFTypeRefs
Blocks
API Markup
Bilingual Targets
Index
About the Author