Learn WatchKit for iOS

Book description

Learn WatchKit for iOS covers the development of applications for the new Apple Watch using the WatchKit framework in iOS 8 and the Swift programming language. In this book, an Apple Watch application is an extension to an existing iOS app and is packaged and submitted to the App Store along with it. Using a suite of simple examples, Kim Topley, co-author of Beginning iPhone Development with Swift, introduces and explains every feature of WatchKit and the associated technologies that you’ll need to understand to build Apple Watch applications for iOS 8, culminating in a complete WatchKit application that shows weather forecast information for various cities around the world on the Apple Watch.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Author
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Chapter 1: Welcome to the Apple Watch
    1. Your First Watch Application
      1. Creating a WatchKit Application
      2. Building the User Interface
      3. Running the Application on the Simulator
      4. Running the Application on an Apple Watch
    2. Some Things That a WatchKit Application Can and Can’t Do
    3. Summary
  11. Chapter 2: Interface Controllers and Layout
    1. Interface Controllers
      1. Interface Controller Lifecycle
      2. Navigation and Lifecycle Events
      3. Lifecycle of the WatchKit App Extension
      4. Debugging the WatchKit App Extension and the iOS Application Together
      5. Interface Controller Attributes
      6. Setting the Background Color
      7. Setting the Application Title
    2. Interface Controller Layout
      1. Spacing, Insets, and Screen-Dependent Layout
      2. Groups
    3. Summary
  12. Chapter 3: Watch User Interface Objects
    1. Overview
    2. Labels
      1. Text Layout
      2. Text, Text Color, and Attributed Text
    3. Fonts
      1. Using the Standard Text Styles
      2. Using the System and System Italic Fonts
      3. Using a Custom Font
      4. Setting Fonts in Code
    4. Images
      1. Using an Image as a Background
      2. The Image Interface Objectimage interface object
      3. AnimationAnimation
      4. Dynamic Image Content
    5. Summary
  13. Chapter 4: More Watch User Interface Objects
    1. Buttons
      1. Creating and Configuring Buttons
      2. Actions and State
      3. Using a Group as the Content of a Button
    2. Sliders
    3. Switches
    4. Displaying the Date and Time
      1. Basic Usage
      2. Custom Formatting
      3. Changing the Timezone and Calendar
    5. Displaying a Timer
      1. Timer Formatting Options
      2. Timer Behavior
    6. WatchKit Maps
      1. Displaying a Map
      2. Setting the Map Region
      3. Adding an Annotation
      4. Using Core Location to Get the User’s Location
    7. Summary
  14. Chapter 5: Controller Navigation
    1. Hierarchical Navigation
      1. Manual Controller Navigation
      2. Using a Segue to Push a Controller
    2. Page-Based Navigation
      1. Constructing a Page-Based Application in the Storyboard
      2. Using Pages Constructed at Run Time
    3. Presenting an Interface Controller
      1. Getting Text Input
      2. Presenting a Controller Programmatically
      3. Presenting a Controller from the Storyboard
    4. Summary
  15. Chapter 6: Tables and Menus
    1. WatchKit Tables
      1. Adding the Controllers and the Table to the Storyboard
      2. Configuring the Table Rows
      3. Defining the Interface between the Controllers
      4. Implementing the Initial Interface Controller
      5. Presenting the Configuration Controller
      6. Implementing the Configuration Controller
      7. More Table Manipulation
    2. Menus
      1. Adding a Menu to an Interface Controller
      2. Adding a Menu in the Storyboard
      3. Adding Menu Items Programmatically
    3. Summary
  16. Chapter 7: Building a WatchKit App
    1. The WatchKit Weather Application
    2. Sharing the Data Model
    3. The Weather Application Data Model
    4. The City Model
    5. The Displayed City Model
    6. The Weather Model
    7. Weather Model Loading
    8. Weather Model Persistence
    9. Mechanisms for Sharing
    10. Sharing Weather Data
    11. Sharing Displayed City Info
    12. Sharing Code
    13. Sending a Request to an iOS Application
    14. Sending a Notification to the WatchKit Extension
    15. Building the WatchKit Weather App
    16. Moving Shared Code to a Framework
    17. Adding the Darwin Bridge to the Framework
    18. Moving the Shared Model Classes
    19. Adding the WatchKit Extension and Creating the App Group
    20. Updating the DisplayedCityInfoModel Class
    21. Updating the Weather Model Classes
    22. Adding the WatchKit Request Handler
    23. Implementing the Main Interface Controller
    24. Adding the Table to the Storyboard
    25. Building and Maintaining the Table
    26. Implement the Forecast Detail Interface Controller
    27. Adding the Controller to the Storyboard
    28. Implementing the DetailsInterfaceController class
    29. Summary
  17. Chapter 8: Glances, Settings, and Handoff
    1. Glances
      1. Adding a Glance to a Project
      2. Running the Glance
      3. Implementing the Weather App Glance
    2. Using Watch App Settings
      1. Creating the Watch App Settings Bundle
      2. Implementing the Glance View Options
    3. Implementing Handoff
    4. Summary
  18. Chapter 9: Notifications
    1. Default Notification Handling
      1. Local Notifications on the iPhone
      2. Local Notifications on the Watch
      3. Notifications with Actions
    2. Handling Notifications in Your WatchKit App
      1. Default WatchKit Notification Handling
      2. Adding the Static Long Look Notification Scene
      3. Adding the Dynamic Long Look Notification Scene
      4. Notifications and the Simulator
    3. Summary
  19. Index

Product information

  • Title: Learn WatchKit for iOS
  • Author(s): Kim Topley
  • Release date: July 2015
  • Publisher(s): Apress
  • ISBN: 9781484210253