iOS 13 Programming Fundamentals with Swift

Book description

Move into iOS development by getting a firm grasp of its fundamentals, including the Xcode 10 IDE, Cocoa Touch, and the latest version of Apple’s acclaimed programming language, Swift 5. With this thoroughly updated guide, you’ll learn the Swift language, understand Apple’s Xcode development tools, and discover the Cocoa framework.

  • Explore Swift’s object-oriented concepts
  • Become familiar with built-in Swift types
  • Dive deep into Swift objects, protocols, and generics
  • Tour the lifecycle of an Xcode project
  • Learn how nibs are loaded
  • Understand Cocoa’s event-driven design
  • Communicate with C and Objective-C

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 13.

Publisher resources

View/Submit Errata

Table of contents

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

Product information

  • Title: iOS 13 Programming Fundamentals with Swift
  • Author(s): Matt Neuburg
  • Release date: October 2019
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9781492074533