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

Book Description

Ready to build truly stunning apps for iPhone, iPad, and Apple Watch? This cookbook—written exclusively in Swift 3—provides more than 120 proven solutions for tackling the latest features in iOS 10 and watchOS 3. With these code-rich recipes, you’ll learn how to build dynamic voice interfaces with Siri and messaging apps with iMessage. You’ll also learn how to use interactive maps, multitasking functionality, the 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. O’Reilly Safari
    6. How to Contact Us
      1. Acknowledgments
  2. iMessage Stickers and Apps
    1. 1.1. Setting Up a Sticker Pack Application
    2. 1.2. Adjusting Sticker Sizes
    3. 1.3. Building a Full-Fledged iMessage Application
    4. 1.4. Adding an iMessage App Extension to an Existing App
    5. 1.5. Utilizing an Expanded View in a Sticker Pack App
    6. 1.6. Appending Rich Information to Stickers
    7. 1.7. Creating Interactive Conversations with iMessage Apps
  3. SiriKit
    1. 2.1. Setting Up Your Project for Siri
    2. 2.2. Defining an Intent Handler
    3. 2.3. Resolving Ambiguity in an Intent
    4. 2.4. Reporting Progress for Resolving an Intent
    5. 2.5. Handling an Intent
  4. Measurements and Units
    1. 3.1. Converting Between and Working with Length Units
    2. 3.2. Working with and Switching Between Angle Units
    3. 3.3. Representing and Converting Between Durations of Time
    4. 3.4. Using and Working with Frequency Units
    5. 3.5. Working with and Using Power Units
    6. 3.6. Representing and Comparing Temperature Units
    7. 3.7. Working with and Converting Volume Units
  5. Core Data
    1. 4.1. Designing Your Database Scheme
    2. 4.2. Writing Data to the Database
    3. 4.3. Reading Data from the Database
    4. 4.4. Searching for Data in the Database
    5. 4.5. Performing Background Tasks with Core Data
  6. Swift 3.0, Xcode 8, and Interface Builder
    1. 5.1. Handling Errors in Swift
    2. 5.2. Specifying Preconditions for Methods
    3. 5.3. Ensuring the Execution of Code Blocks Before Exiting Methods
    4. 5.4. Checking for API Availability
    5. 5.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. 5.6. Exporting Device-Specific Binaries
    7. 5.7. Linking Separate Storyboards Together
    8. 5.8. Adding Multiple Buttons to the Navigation Bar
    9. 5.9. Optimizing Your Swift Code
    10. 5.10. Showing the Header View of Your Swift Classes
    11. 5.11. Creating Your Own Set Types
    12. 5.12. Conditionally Extending a Type
    13. 5.13. Building Equality Functionality into Your Own Types
    14. 5.14. Looping Conditionally Through a Collection
    15. 5.15. Designing Interactive Interface Objects in Playgrounds
    16. 5.16. Grouping Switch Statement Cases Together
    17. 5.17. Bundling and Reading Data in Your Apps
  7. The User Interface
    1. 6.1. Animating Views
    2. 6.2. Attaching Live Views to Playgrounds
    3. 6.3. Running Playgrounds as Interactive and Continuous Apps
    4. 6.4. Arranging Your Components Horizontally or Vertically
    5. 6.5. Customizing Stack Views for Different Screen Sizes
    6. 6.6. Creating Anchored Constraints in Code
    7. 6.7. Allowing Users to Enter Text in Response to Local and Remote Notifications
    8. 6.8. Dealing with Stacked Views in Code
    9. 6.9. Showing Web Content in Safari View Controller
    10. 6.10. Laying Out Text-Based Content on Your Views
    11. 6.11. Improving Touch Rates for Smoother UI Interactions
    12. 6.12. Supporting Right-to-Left Languages
    13. 6.13. Associating Keyboard Shortcuts with View Controllers
    14. 6.14. Recording the Screen and Sharing the Video
  8. Apple Watch
    1. 7.1. Downloading Files onto the Apple Watch
    2. 7.2. Noticing Changes in Pairing State Between the iOS and Watch Apps
    3. 7.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. 7.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. 7.5. Transferring Files to and from the Watch
    6. 7.6. Communicating Interactively Between iOS and watchOS
    7. 7.7. Setting Up Apple Watch for Custom Complications
    8. 7.8. Constructing Small Complications with Text and Images
    9. 7.9. Displaying Time Offsets in Complications
    10. 7.10. Displaying Dates in Complications
    11. 7.11. Displaying Times in Complications
    12. 7.12. Displaying Time Intervals in Complications
    13. 7.13. Recording Audio in Your Watch App
    14. 7.14. Playing Local and Remote Audio and Video in Your Watch App
  9. Contacts
    1. 8.1. Creating Contacts
    2. 8.2. Searching for Contacts
    3. 8.3. Updating Contacts
    4. 8.4. Deleting Contacts
    5. 8.5. Formatting Contact Data
    6. 8.6. Picking Contacts with the Prebuilt System UI
    7. 8.7. Creating Contacts with a Prebuilt System UI
    8. 8.8. Displaying Contacts with a Prebuilt System UI
  10. Extensions
    1. 9.1. Creating Safari Content Blockers
    2. 9.2. Creating Shared Links for Safari
    3. 9.3. Maintaining Your App’s Indexed Content
  11. Web and Search
    1. 10.1. Making Your App’s Content Searchable
    2. 10.2. Making User Activities Searchable
    3. 10.3. Deleting Your App’s Searchable Content
  12. Multitasking
    1. 11.1. Supporting Split Views
    2. 11.2. Adding Picture in Picture Playback Functionality
    3. 11.3. Handling Low Power Mode and Providing Alternatives
  13. Maps and Location
    1. 12.1. Displaying a Specific Location on the Map
    2. 12.2. Requesting the User’s Location a Single Time
    3. 12.3. Requesting the User’s Location in the Background
    4. 12.4. Customizing the Tint Color of Pins on the Map
    5. 12.5. Providing Detailed Pin Information with Custom Views
    6. 12.6. Displaying Traffic, Scale, and Compass Indicators on the Map
    7. 12.7. Providing an ETA for Transit Transport Type
    8. 12.8. Launching the iOS Maps App in Transit Mode
    9. 12.9. Showing Maps in Flyover Mode
  14. UI Testing
    1. 13.1. Preparing Your Project for UI Testing
    2. 13.2. Automating UI Test Scripts
    3. 13.3. Testing Text Fields, Buttons, and Labels
    4. 13.4. Finding UI Components
    5. 13.5. Long-Pressing on UI Elements
    6. 13.6. Typing Inside Text Fields
    7. 13.7. Swiping on UI Elements
    8. 13.8. Tapping UI Elements
  15. Core Motion
    1. 14.1. Querying Pace and Cadence Information
    2. 14.2. Recording and Reading Accelerometer Data
  16. Security
    1. 15.1. Protecting Your Network Connections with ATS
    2. 15.2. Binding Keychain Items to Passcode and Touch ID
    3. 15.3. Opening URLs Safely
    4. 15.4. Authenticating the User with Touch ID and Timeout
  17. Multimedia
    1. 16.1. Reading Out Text with the Default Siri Alex Voice
    2. 16.2. Downloading and Preparing Remote Media for Playback
    3. 16.3. Enabling Spoken Audio Sessions
  18. UI Dynamics
    1. 17.1. Adding a Radial Gravity Field to Your UI
    2. 17.2. Creating a Linear Gravity Field on Your UI
    3. 17.3. Creating Turbulence Effects with Animations
    4. 17.4. Adding Animated Noise Effects to Your UI
    5. 17.5. Creating a Magnetic Effect Between UI Components
    6. 17.6. Designing a Velocity Field on Your UI
    7. 17.7. Handling Collisions Between Nonrectangular Views
  19. Index