Learning WatchKit Programming: A Hands-On Guide to Creating watchOS 2 Applications, Second Edition

Book description

Create Breakthrough Apple Watch Apps with the New watchOS 2 and the Updated WatchKit Framework!

Apple Watch is improving quickly: Using Apple’s new watchOS 2 operating system and the updated WatchKit framework, you can create tomorrow’s hottest wearable apps. Learning WatchKit Programming, Second Edition, will help you master these technologies and gain the same “early mover” advantage that early iPhone developers enjoyed.

Leading iOS development trainer and author Wei-Meng Lee guides you step by step through architecting, designing, and building cutting-edge Apple Watch apps. You’ll learn how to make the most of the newest platform improvements, including direct programmatic access to key hardware features; support for new Watch Connectivity Framework APIs; and new ways to use location, consume web services, and persist data.

Using practical Swift code examples designed for clarity and simplicity, Lee guides you through building apps from the ground up. You’ll learn how to build native watch apps that perform exceptionally well on their own and how to integrate your apps with iPhones to do even more.

Coverage includes

  • Writing high-performance, native watch apps that run independently of the iPhone

  • Accessing hardware, including Digital Crown, microphone, and Taptic Engine

  • Storyboarding apps and testing them on the Apple Watch Simulator

  • Mastering Apple Watch’s multiple-screen navigation

  • Building efficient interfaces with Apple Watch UI controls

  • Creating and programming “complications”–apps that display data on the watch face, such as alarms, tachymeters, chronographs, and calendars

  • Displaying information via labels, images, or tables

  • Passing and returning data to Interface Controllers

  • Integrating location services into Apple Watch apps

  • Using Watch Connectivity Framework APIs to link watch and iOS apps

  • Calling and consuming web services

  • Persisting data on the watch

  • Displaying short- and long-look notifications Implementing glances to help users gather information faster 

  • This guide will help you extend your existing iOS skills, build apps that solve a whole new set of problems, and reach millions of people in the fast-growing Apple Watch marketplace.

    All of this book’s sample Swift code is available for download at informit.com/title/9780134398983. (Register your book to gain access.)

    Table of contents

    1. About This E-Book
    2. Title Page
    3. Copyright Page
    4. Dedication Page
    5. Contents at a Glance
    6. Contents
    7. Preface
      1. What You’ll Need
      2. How This Book Is Organized
      3. About the Sample Code
        1. Getting the Sample Code
      4. Contacting the Author
    8. Acknowledgments
    9. About the Author
    10. 1. Getting Started with WatchKit Programming
      1. Specifications of the Apple Watch
      2. Getting the Tools for Development
      3. Understanding the WatchKit App Architecture
        1. Deploying Apple Watch Apps
        2. Interaction between the Apple Watch and iPhone
      4. Types of Apple Watch Applications
      5. Hello, World!
        1. Creating an iPhone Project
        2. Examining the Storyboard
        3. WatchKit App Lifecycle
        4. Modifying the Interface Controller
        5. Running the Application on the Simulator
      6. Summary
    11. 2. Apple Watch Interface Navigation
      1. Interface Controllers and Storyboard
        1. Lifecycle of an Interface Controller
      2. Navigating between Interface Controllers
        1. Hierarchical Navigation
        2. Page-Based Navigation
        3. Passing Data between Interface Controllers
        4. Customizing the Title of the Chevron or Cancel Button
        5. Navigating Using Code
        6. Presenting a Series of Pages
        7. Changing the Current Page to Display
        8. Returning Data from an Interface Controller
      3. Summary
    12. 3. Responding to User Actions
      1. Using the Tap Gesture to Interact with Controls
        1. Button
        2. Switch
        3. Slider
        4. Alerts and Action Sheets
      2. Summary
    13. 4. Displaying and Gathering Information
      1. Displaying Information
        1. Label
        2. Image
        3. Table
        4. Picker
        5. Playing Media Files
      2. Gathering Information
        1. Getting Text Inputs
        2. Getting Emojis
      3. Laying Out the Controls
      4. Force Touch
        1. Displaying a Context Menu
        2. Adding Menu Items Programmatically
      5. Summary
    14. 5. Accessing the Apple Watch Hardware
      1. Making Phone Calls and Sending Messages
      2. Recording Audio
      3. Digital Crown
      4. Accelerometer
      5. Taptic Engine
      6. Summary
    15. 6. Programming Complications
      1. Introducing the ClockKit Framework
        1. Placement for Complications
        2. Using the Template Classes
      2. Building a Movie Showtime Complication Example
        1. Creating the Project
        2. Selecting Complication Families Support
        3. Creating the Complication Placeholder Template
        4. Setting Privacy Behavior
        5. Populating the Complications with Real Data
        6. Time Travel
        7. Setting the Refresh Frequency
      3. Summary
    16. 7. Interfacing with iOS Apps
      1. Introducing the Watch Connectivity Framework
        1. Types of Communication
        2. Using the Watch Connectivity Framework
        3. Comparing the Different Modes
      2. Connecting to the Outside World
        1. Getting Location Data
        2. Display Map
        3. Accessing Web Services
      3. Saving Data
        1. Creating the Project
        2. Writing to Files
        3. Using NSUserDefaults
      4. Summary
    17. 8. Displaying Notifications
      1. What Is a Notification?
      2. Types of Notifications on the Apple Watch
        1. Implementing the Short-Look Interface
        2. Implementing the Long-Look Interface
      3. Summary
    18. 9. Displaying Glances
      1. What Is a Glance?
      2. Implementing Glances
        1. Customizing the Glance
        2. Testing the Glance
      3. Making the Glance Useful
        1. Implementing Background Fetch
      4. Updating the Glance
      5. Summary
    19. Index
    20. Code Snippets

    Product information

    • Title: Learning WatchKit Programming: A Hands-On Guide to Creating watchOS 2 Applications, Second Edition
    • Author(s):
    • Release date: December 2015
    • Publisher(s): Addison-Wesley Professional
    • ISBN: 9780134399164