You are previewing iOS 9 Swift Programming Cookbook.
O'Reilly logo
iOS 9 Swift Programming Cookbook

Book Description

Ready to build stunning apps for iPhone, iPad, and Apple Watch? This cookbook—completely rewritten with all-new material—provides 90 proven solutions for tackling the latest features in iOS 9 and watchOS 2.0. Written exclusively in Apple’s Swift language, these code-rich recipes show you how to use dynamic user interfaces, interactive maps, multitasking functionality, Apple’s new UI Testing framework, and many other features.

Table of Contents

  1. Preface
    1. Audience
    2. Organization of This Book
    3. Additional Resources
    4. Using Code Examples
    5. Acknowledgments
  2. Swift 2.0, Xcode 7, and Interface Builder
    1. 1.1. Handling Errors in Swift
    2. 1.2. Specifying Preconditions for Methods
    3. 1.3. Ensuring the Execution of Code Blocks Before Exiting Methods
    4. 1.4. Checking for API Availability
    5. 1.5. Categorizing and Downloading Assets to Get <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="keep-together">Smaller Binaries</span>
    6. 1.6. Exporting Device-Specific Binaries
    7. 1.7. Linking Separate Storyboards Together
    8. 1.8. Adding Multiple Buttons to the Navigation Bar
    9. 1.9. Optimizing Your Swift Code
    10. 1.10. Showing the Header View of Your Swift Classes
    11. 1.11. Creating Your Own Set Types
    12. 1.12. Conditionally Extending a Type
    13. 1.13. Building Equality Functionality into Your Own Types
    14. 1.14. Looping Conditionally Through a Collection
    15. 1.15. Designing Interactive Interface Objects in Playgrounds
    16. 1.16. Grouping Switch Statement Cases Together
    17. 1.17. Bundling and Reading Data in Your Apps
  3. Apple Watch
    1. 2.1. Downloading Files onto the Apple Watch
    2. 2.2. Noticing Changes in Pairing State Between the iOS and Watch Apps
    3. 2.3. Transferring Small Pieces of Data to and <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="keep-together">from the Watch</span>
    4. 2.4. Transferring Dictionaries in Queues to and from <span xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class="keep-together">the Watch</span>
    5. 2.5. Transferring Files to and from the Watch
    6. 2.6. Communicating Interactively Between iOS and watchOS
    7. 2.7. Setting Up Apple Watch for Custom Complications
    8. 2.8. Constructing Small Complications with Text and Images
    9. 2.9. Displaying Time Offsets in Complications
    10. 2.10. Displaying Dates in Complications
    11. 2.11. Displaying Times in Complications
    12. 2.12. Displaying Time Intervals in Complications
    13. 2.13. Recording Audio in Your Watch App
    14. 2.14. Playing Local and Remote Audio and Video in Your Watch App
  4. The User Interface
    1. 3.1. Arranging Your Components Horizontally or Vertically
    2. 3.2. Customizing Stack Views for Different Screen Sizes
    3. 3.3. Creating Anchored Constraints in Code
    4. 3.4. Allowing Users to Enter Text in Response to Local and Remote Notifications
    5. 3.5. Dealing with Stacked Views in Code
    6. 3.6. Showing Web Content in Safari View Controller
    7. 3.7. Laying Out Text-Based Content on Your Views
    8. 3.8. Improving Touch Rates for Smoother UI Interactions
    9. 3.9. Supporting Right-to-Left Languages
    10. 3.10. Associating Keyboard Shortcuts with View Controllers
    11. 3.11. Recording the Screen and Sharing the Video
  5. Contacts
    1. 4.1. Creating Contacts
    2. 4.2. Searching for Contacts
    3. 4.3. Updating Contacts
    4. 4.4. Deleting Contacts
    5. 4.5. Formatting Contact Data
    6. 4.6. Picking Contacts with the Prebuilt System UI
    7. 4.7. Creating Contacts with a Prebuilt System UI
    8. 4.8. Displaying Contacts with a Prebuilt System UI
  6. Extensions
    1. 5.1. Creating Safari Content Blockers
    2. 5.2. Creating Shared Links for Safari
    3. 5.3. Maintaining Your App’s Indexed Content
  7. Web and Search
    1. 6.1. Making Your App’s Content Searchable
    2. 6.2. Making User Activities Searchable
    3. 6.3. Deleting Your App’s Searchable Content
  8. Multitasking
    1. 7.1. Adding Picture in Picture Playback Functionality
    2. 7.2. Handling Low Power Mode and Providing Alternatives
  9. Maps and Location
    1. 8.1. Requesting the User’s Location a Single Time
    2. 8.2. Requesting the User’s Location in Background
    3. 8.3. Customizing the Tint Color of Pins on the Map
    4. 8.4. Providing Detailed Pin Information with Custom Views
    5. 8.5. Displaying Traffic, Scale, and Compass Indicators on the Map
    6. 8.6. Providing an ETA for Transit Transport Type
    7. 8.7. Launching the iOS Maps App in Transit Mode
    8. 8.8. Showing Maps in Flyover Mode
  10. UI Testing
    1. 9.1. Preparing Your Project for UI Testing
    2. 9.2. Automating UI Test Scripts
    3. 9.3. Testing Text Fields, Buttons, and Labels
    4. 9.4. Finding UI Components
    5. 9.5. Long-Pressing on UI Elements
    6. 9.6. Typing Inside Text Fields
    7. 9.7. Swiping on UI Elements
    8. 9.8. Tapping UI Elements
  11. Core Motion
    1. 10.1. Querying Pace and Cadence Information
    2. 10.2. Recording and Reading Accelerometer Data
  12. Security
    1. 11.1. Protecting Your Network Connections with ATS
    2. 11.2. Binding Keychain Items to Passcode and Touch ID
    3. 11.3. Opening URLs Safely
    4. 11.4. Authenticating the User with Touch ID and Timeout
  13. Multimedia
    1. 12.1. Reading Out Text with the Default Siri Alex Voice
    2. 12.2. Downloading and Preparing Remote Media for Playback
    3. 12.3. Enabling Spoken Audio Sessions
  14. UI Dynamics
    1. 13.1. Adding a Radial Gravity Field to Your UI
    2. 13.2. Creating a Linear Gravity Field on Your UI
    3. 13.3. Creating Turbulence Effects with Animations
    4. 13.4. Adding Animated Noise Effects to Your UI
    5. 13.5. Creating a Magnetic Effect Between UI Components
    6. 13.6. Designing a Velocity Field on Your UI
    7. 13.7. Handling Nonrectangular Views
  15. Index