You are previewing iOS 10 Programming Fundamentals with Swift.
O'Reilly logo
iOS 10 Programming Fundamentals with Swift

Book Description

Move into iOS development by getting a firm grasp of its fundamentals, including the Xcode IDE, the Cocoa Touch framework, and Swift 3—the latest version of Apple’s acclaimed programming language. With this thoroughly updated guide, you’ll learn Swift’s object-oriented concepts, understand how to use Apple’s development tools, and discover how Cocoa provides the underlying functionality iOS apps need to have.

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

Table of Contents

  1. Preface
    1. The Scope of This Book
    2. Versions
    3. Acknowledgments
    4. From the Programming iOS 4 Preface
    5. Conventions Used in This Book
    6. Using Code Examples
    7. Safari® Books Online
    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. self
      14. Privacy
      15. Design
        1. Object Types and APIs
        2. Instance Creation, Scope, and Lifetime
        3. Summary and Conclusion
    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
      8. Function In Function
      9. Recursion
      10. Function As Value
      11. Anonymous Functions
      12. Define-and-Call
      13. Closures
        1. How Closures Improve Code
        2. Function Returning Function
        3. Closure Setting a Captured Variable
        4. Closure Preserving Its 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 Initializer
      4. Computed Variables
      5. Setter Observers
      6. Lazy Initialization
      7. Built-In Simple Types
        1. Bool
        2. Numbers
        3. String
        4. Character
        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
        6. Instance References
      2. Enums
        1. Raw Values
        2. Associated Values
        3. Enum Initializers
        4. Enum Properties
        5. Enum Methods
        6. Why Enums?
      3. Structs
        1. Struct Initializers, Properties, and Methods
        2. Struct As Namespace
      4. Classes
        1. Value Types and Reference Types
        2. Subclass and Superclass
        3. Class Initializers
        4. Class Deinitializer
        5. Class Properties and Methods
      5. Polymorphism
      6. Casting
      7. Type Reference
      8. Protocols
        1. Why Protocols?
        2. Protocol Type Testing and Casting
        3. Declaring a Protocol
        4. Optional Protocol Members
        5. Class Protocol
        6. Implicitly Required Initializers
        7. Literal Convertibles
      9. Generics
        1. Generic Declarations
        2. Type Constraints
        3. Explicit Specialization
        4. Associated Type Chains
        5. Additional Constraints
      10. Extensions
        1. Extending Object Types
        2. Extending Protocols
        3. 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. Operators
      3. Privacy
        1. Private and Fileprivate
        2. Public and Open
        3. Privacy Rules
      4. Introspection
      5. Memory Management
        1. Weak References
        2. Unowned References
        3. Weak and Unowned References in Anonymous Functions
        4. Memory Management of Protocol-Typed References
  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. The Project File and Its Dependents
      4. The Target
        1. Build Phases
        2. Build Settings
        3. Configurations
        4. Schemes and Destinations
      5. From Project to Running App
        1. Build Settings
        2. Property List Settings
        3. Nib Files
        4. Additional Resources
        5. Code Files and the App Launch Process
        6. Frameworks and SDKs
      6. Renaming Parts of a Project
    2. 7. Nib Management
      1. The Nib Editor Interface
        1. Document Outline
        2. Canvas
        3. Inspectors and Libraries
      2. Nib Loading
        1. When Nibs Are Loaded
        2. Manual Nib Loading
      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. Symbols
      5. Header Files
      6. Sample Code
      7. Internet Resources
    4. 9. Life Cycle of a Project
      1. Device Architecture and Conditional Code
        1. Backward Compatibility
        2. Device Type
      2. Version Control
      3. Editing and Navigating Your Code
        1. Autocompletion
        2. Snippets
        3. Fix-it and Live Syntax Checking
        4. Navigation
        5. Finding
      4. Running in the Simulator
      5. Debugging
        1. Caveman Debugging
        2. The Xcode Debugger
      6. Testing
      7. Clean
      8. Running on a Device
        1. Obtaining a Developer Program Membership
        2. Signing an App
        3. Automatic Development Signing
        4. Obtaining a Development Certificate Manually
        5. Obtaining a Development Provisioning Profile Manually
        6. Running the App
        7. Managing Certificates, Profiles, and Devices
      9. Profiling
        1. Gauges
        2. Memory Debugging
        3. Instruments
      10. Localization
        1. Localizing the Info.plist
        2. Localizing a Nib File
        3. Localizing Code Strings
        4. Localizing With XML Files
      11. Distribution
        1. Making an Archive
        2. Obtaining a Distribution Certificate Manually
        3. Obtaining a Distribution Profile Manually
        4. Ad Hoc Distribution
      12. Final App Preparations
        1. Icons in the App
        2. Other Icons
        3. Launch Images
        4. Screenshots and Video Previews
        5. Property List Settings
      13. 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. Informal Protocols
        2. Optional Methods
      4. Some Foundation Classes
        1. Useful Structs and Constants
        2. NSString and Friends
        3. NSDate and Friends
        4. NSNumber
        5. NSValue
        6. NSData
        7. NSMeasurement and Friends
        8. Equality and Comparison
        9. NSArray and NSMutableArray
        10. NSDictionary and NSMutableDictionary
        11. NSSet and Friends
        12. NSIndexSet
        13. NSNull
        14. Immutable and Mutable
        15. Property Lists
      5. Accessors, Properties, and Key–Value Coding
        1. Swift Accessors
        2. Key–Value Coding
        3. Uses of Key–Value Coding
        4. KVC and Outlets
        5. Key Paths
        6. Array Accessors
      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
      7. The Responder Chain
        1. Deferring Responsibility
        2. Nil-Targeted Actions
      8. Key–Value Observing
      9. Swamped by Events
      10. 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
      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 by Instantiation
      2. Visibility by Relationship
      3. Global Visibility
      4. Notifications and Key–Value Observing
      5. Model–View–Controller
    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. Bridged Types and Boxed Types
        4. Objective-C Methods
        5. Objective-C Initializers and Factories
        6. Selectors
        7. CFTypeRefs
        8. Blocks
        9. API Markup
      3. Bilingual Targets
  5. Index