WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application...

155
© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple. WatchKit In-Depth, Part 1 Andrew Platzer WatchKit Engineer Forest Hill WatchKit Engineer App Frameworks #WWDC15 Session 207

Transcript of WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application...

Page 1: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

© 2015 Apple Inc. All rights reserved. Redistribution or public display not permitted without written permission from Apple.

WatchKit In-Depth, Part 1

Andrew Platzer WatchKit EngineerForest Hill WatchKit Engineer

App Frameworks #WWDC15

Session 207

Page 2: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WatchKit In-Depth, Part 1

Page 3: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WatchKit In-Depth, Part 1

ArchitectureResources and DataMigrationEnhancements

Page 4: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Architecture

Watch App for watchOS 2

Page 5: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatch App for watchOS 2

Components• iOS application• watchOS WatchKit extension• watchOS Watch application

Page 6: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatch App for watchOS 2

Page 7: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

iPhone

ArchitectureWatch App for watchOS 2

Page 8: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

iPhone

ArchitectureWatch App for watchOS 2

iOS Application

Resources

Code

Page 9: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

iPhone

ArchitectureWatch App for watchOS 2

iOS Application

Resources

Code

Watch App

Resources

Interface

Page 10: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

iPhone

ArchitectureWatch App for watchOS 2

iOS Application

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 11: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatch App for watchOS 2

iPhone

iOS Application

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 12: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Apple Watch

ArchitectureWatch App for watchOS 2

iPhone

iOS Application

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 13: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Apple Watch

ArchitectureWatch App for watchOS 2

iPhone

iOS Application

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 14: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Apple Watch

ArchitectureWatch App for watchOS 2

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 15: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatch App for watchOS 2

Watch App

Resources

Interface

WatchKit Extension

Resources

Code

Page 16: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatch App for watchOS 2

Watch App

Resources

Interface

WatchKit Extension

Resources

CodeCodeInterface

Page 17: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit App

Page 18: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Page 19: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Edit with Interface Builder

Page 20: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Edit with Interface BuilderInterface Elements

• Label• Image• Button• Switch• Slider• Date Label

• Timer Label• Separator• Group• Table• Menus• Map

Page 21: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Edit with Interface BuilderInterface Elements

• Label• Image• Button• Switch• Slider• Date Label

• Timer Label• Separator• Group• Table• Menus• Map

• Picker • Movie

Page 22: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Page 23: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Page 24: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Page 25: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface.storyboard

Page 26: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

Roles• Application• Glance• Notification• Complication

Page 27: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

Roles• Application WKInterfaceController • Glance WKInterfaceController • Notification WKUserNotificationInterfaceController • Complication CLKComplicationDataSource

Page 28: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

Roles• Application WKInterfaceController • Glance WKInterfaceController • Notification WKUserNotificationInterfaceController • Complication CLKComplicationDataSource

Creating Complications with ClockKit Pacific Heights Wednesday 11:00AM

Page 29: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

Page 30: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController

Page 31: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties

Page 32: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties• Menu handling

Page 33: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties• Menu handling• Controller navigation and paging

Page 34: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties• Menu handling• Controller navigation and paging• Controller modal presentation

Page 35: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties• Menu handling• Controller navigation and paging• Controller modal presentation• Alert and action sheets

Page 36: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureWatchKit Extension

WKInterfaceController• Interface properties• Menu handling• Controller navigation and paging• Controller modal presentation• Alert and action sheets• System UI — text input, video, audio

Page 37: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface properties

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") }

Page 38: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface properties

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") }

Page 39: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ArchitectureInterface properties

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") }

Page 40: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Resources and Data

Application and Extension

Page 41: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

Multiple locations• Watch App bundle• WatchKit Extension bundle

Page 42: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

Multiple locations• Watch App bundle• WatchKit Extension bundle

Page 43: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! @IBOutlet weak var extImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") extImage.setImageNamed("ExtensionImage") }

Page 44: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! @IBOutlet weak var extImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") extImage.setImageNamed("ExtensionImage") }

Page 45: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

class InterfaceController: WKInterfaceController { @IBOutlet weak var appImage: WKInterfaceImage! @IBOutlet weak var extImage: WKInterfaceImage! override func willActivate() { super.willActivate() appImage.setImageNamed("ApplicationImage") extImage.setImageNamed("ExtensionImage") }

Page 46: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

class InterfaceController: WKInterfaceController { … appImage.setImageNamed("ApplicationImage") let image = UIImage(named: "ExtensionImage") extImage.setImage(image) }

Page 47: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

ResourcesStatic Resources

class InterfaceController: WKInterfaceController { … appImage.setImageNamed("ApplicationImage") let image = UIImage(named: "ExtensionImage") extImage.setImage(image) }

Page 48: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

Page 49: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

Document folder• Non-purgeable• Not restored

Page 50: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

Document folder• Non-purgeable• Not restored

Caches folder• Purgeable

Page 51: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

func saveData(data: NSData, fileName: String) { let fileManager = NSFileManager.defaultManager() guard let documentDir = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first else { return } let url = documentDirectory.URLByAppendingPathComponent(fileName) data.writeToURL(url, atomically: true) }

Page 52: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

func saveData(data: NSData, fileName: String) { let fileManager = NSFileManager.defaultManager() guard let documentDir = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first else { return } let url = documentDirectory.URLByAppendingPathComponent(fileName) data.writeToURL(url, atomically: true) }

Page 53: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataLocal data storage

func saveData(data: NSData, fileName: String) { let fileManager = NSFileManager.defaultManager() guard let documentDir = fileManager.URLsForDirectory(.DocumentDirectory, inDomains: .UserDomainMask).first else { return } let url = documentDirectory.URLByAppendingPathComponent(fileName) data.writeToURL(url, atomically: true) }

Page 54: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Page 55: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Application• Plays media files• Records audio to a file

Page 56: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Application• Plays media files• Records audio to a file

Extension• Downloads media files• Reads recorded audio files

Page 57: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Page 58: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Must use a shared container

Page 59: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

Must use a shared container Enable App Groups in Xcode• Extension• Application

Page 60: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

func recordAudio(name: String) {

    let fileManager = NSFileManager.defaultManager()     let container = fileManager.containerURLForSecurityApplicationGroupIdentifier("group.myapp")!

    let fileName = name.stringByAppendingPathExtension("mp4")!     let audioFileURL = container.URLByAppendingPathComponent(fileName)

    self.presentAudioRecordingControllerWithOutputURL(audioFileURL, ...

Page 61: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataMedia

func recordAudio(name: String) {

    let fileManager = NSFileManager.defaultManager()     let container = fileManager.containerURLForSecurityApplicationGroupIdentifier("group.myapp")!

    let fileName = name.stringByAppendingPathExtension("mp4")!     let audioFileURL = container.URLByAppendingPathComponent(fileName)

    self.presentAudioRecordingControllerWithOutputURL(audioFileURL, ...

Page 62: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataTransferring data

Page 63: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataTransferring data

NSURLSession

Page 64: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataTransferring data

NSURLSessionWatchConnectivity

Page 65: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

Page 66: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

Direct access to internet• http:// and https://

Page 67: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

Direct access to internet• http:// and https://

Background uploads and downloads• Extension may not be running• Downloaded files must be copied

Page 68: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

class Downloader : NSObject, NSURLSessionDownloadDelegate {     lazy var session: NSURLSession = self.createDownloadSession()

    func createDownloadSession() -> NSURLSession {         let config = NSURLSessionConfiguration .backgroundSessionConfigurationWithIdentifier("Downloader")         return NSURLSession(configuration: config, delegate: self, delegateQueue: nil)     }

    func download(url: NSURL) { let task = session.downloadTaskWithURL(url)!         task.resume()     }

Page 69: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

class Downloader : NSObject, NSURLSessionDownloadDelegate {     lazy var session: NSURLSession = self.createDownloadSession()

    func createDownloadSession() -> NSURLSession {         let config = NSURLSessionConfiguration .backgroundSessionConfigurationWithIdentifier("Downloader")         return NSURLSession(configuration: config, delegate: self, delegateQueue: nil)     }

    func download(url: NSURL) { let task = session.downloadTaskWithURL(url)!         task.resume()     }

Page 70: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

class Downloader : NSObject, NSURLSessionDownloadDelegate {     lazy var session: NSURLSession = self.createDownloadSession()

    func createDownloadSession() -> NSURLSession {         let config = NSURLSessionConfiguration .backgroundSessionConfigurationWithIdentifier("Downloader")         return NSURLSession(configuration: config, delegate: self, delegateQueue: nil)     }

    func download(url: NSURL) { let task = session.downloadTaskWithURL(url)!         task.resume()     }

Page 71: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

class Downloader : NSObject, NSURLSessionDownloadDelegate {     lazy var session: NSURLSession = self.createDownloadSession()

    func createDownloadSession() -> NSURLSession {         let config = NSURLSessionConfiguration .backgroundSessionConfigurationWithIdentifier("Downloader")         return NSURLSession(configuration: config, delegate: self, delegateQueue: nil)     }

    func download(url: NSURL) { let task = session.downloadTaskWithURL(url)!         task.resume()     }

Page 72: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

    func restart() {          session = createDownloadSession()     }

    func URLSession(NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {         let fileManager = NSFileManager.defaultManager()         guard let cacheDir = fileManager.URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask).first else { return }         let cacheURL = cacheDir.URLByAppendingPathComponent(location.lastPathComponent!)

        do { try fileManager.copyItemAtURL(location, toURL: cacheURL) }         catch { print(error) }     }

Page 73: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

    func restart() {          session = createDownloadSession()     }

    func URLSession(NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {         let fileManager = NSFileManager.defaultManager()         guard let cacheDir = fileManager.URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask).first else { return }         let cacheURL = cacheDir.URLByAppendingPathComponent(location.lastPathComponent!)

        do { try fileManager.copyItemAtURL(location, toURL: cacheURL) }         catch { print(error) }     }

Page 74: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

    func restart() {          session = createDownloadSession()     }

    func URLSession(NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {         let fileManager = NSFileManager.defaultManager()         guard let cacheDir = fileManager.URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask).first else { return }         let cacheURL = cacheDir.URLByAppendingPathComponent(location.lastPathComponent!)

        do { try fileManager.copyItemAtURL(location, toURL: cacheURL) }         catch { print(error) }     }

Page 75: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataNSURLSession

    func restart() {          session = createDownloadSession()     }

    func URLSession(NSURLSession, downloadTask: NSURLSessionDownloadTask, didFinishDownloadingToURL location: NSURL) {         let fileManager = NSFileManager.defaultManager()         guard let cacheDir = fileManager.URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask).first else { return }         let cacheURL = cacheDir.URLByAppendingPathComponent(location.lastPathComponent!)

        do { try fileManager.copyItemAtURL(location, toURL: cacheURL) }         catch { print(error) }     }

Page 76: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataWatchConnectivity framework

Watch ↔ Phone• Share data• Transfer files• Talk to counterpart

Page 77: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

DataWatchConnectivity framework

Watch ↔ Phone• Share data• Transfer files• Talk to counterpart

Introducing Watch Connectivity Pacific Heights Thursday 11:00AM

Page 78: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Migration

watchOS 1 ➟ watchOS 2

Page 79: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

Page 80: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1

Page 81: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1• Uses iOS Platform and SDK

Page 82: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1• Uses iOS Platform and SDK• Runs on iPhone

Page 83: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1• Uses iOS Platform and SDK• Runs on iPhone• Share framework with iOS application

Page 84: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1• Uses iOS Platform and SDK• Runs on iPhone• Share framework with iOS application• Image caching

Page 85: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 1

WatchKit extension for watchOS 1• Uses iOS Platform and SDK• Runs on iPhone• Share framework with iOS application• Image caching• openParentApplication()

Page 86: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 2

Page 87: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 2

New watchOS platform and SDK

Page 88: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 2

New watchOS platform and SDKSubset of iOS frameworks available

Page 89: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationwatchOS 2

New watchOS platform and SDKSubset of iOS frameworks availableInclude project frameworks

Page 90: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationReusability

Page 91: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationReusability

Same API• Copy code• Copy resources

Page 92: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationReusability

Same API• Copy code• Copy resources

Improvements• UI responsiveness• Independent operation• New UI elements• Animation

Page 93: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationReusability

Same API• Copy code• Copy resources

Improvements• UI responsiveness• Independent operation• New UI elements• Animation

Layout and Animation Techniques for WatchKit Pacific Heights Thursday 10:00AM

Page 94: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationControllers

Page 95: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationControllers

Same• Interface controller• Glance controller• Notification controller

Page 96: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationControllers

Same• Interface controller• Glance controller• Notification controller

New• Extension delegate• Complication data source

Page 97: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationXcode

Page 98: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationXcode

Existing project• Add watchOS Application target

Page 99: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationXcode

Existing project• Add watchOS Application target

New project• Create iOS App with WatchKit App

Page 100: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

MigrationXcode

Existing project• Add watchOS Application target

New project• Create iOS App with WatchKit App

Building Watch Apps WWDC 2015 Videos

Page 101: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

New APIs in WatchKit for watchOS 2

Forest Hill WatchKit Engineer

Page 102: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateCallback methods for app lifecycle

Page 103: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateCallback methods for app lifecycle

iOSUIApplicationDelegate

Page 104: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateCallback methods for app lifecycle

iOSUIApplicationDelegate

watchOS 2WKExtensionDelegate

Page 105: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateapplicationDidFinishLaunching

Called once on launchPerform app initializationSetup notification observersWarmup services

NOTE: App is not active yet

Page 106: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateapplicationDidBecomeActive

Each time app becomes visually activeActivate timersUpdate any state

Page 107: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateapplicationWillResignActive

Only call before going to backgroundPrepare to be inactiveSave stateDisable running services, timers, etc

Page 108: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateApp lifecycle

func applicationDidFinishLaunching() func applicationDidBecomeActive() func applicationWillResignActive()

Callbacks on app lifecycle only

Page 109: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionDelegateUser Activity

func handleUserActivity(userInfo: [NSObject : AnyObject])

watchOS 1method on root WKInterfaceController

watchOS 2method on WKExtensionDelegate

Page 110: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

User Activity

Page 111: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

User Activity

*This property on WKExtension:var rootInterfaceController: WKInterfaceController

will be coming in a future seed of watchOS 2

Page 112: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

User Activity

*This property on WKExtension:var rootInterfaceController: WKInterfaceController

will be coming in a future seed of watchOS 2

func handleUserActivity(userInfo: [NSObject : AnyObject]) { let rootController = WKExtension.sharedExtension.rootInterfaceController rootController.popToRootController() rootController.doStuffForUserActivity(userInfo)

}

Page 113: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionAnalogous to UIApplication in iOS

SingletonEncapsulates the running application

Page 114: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionAnalogous to UIApplication in iOS

SingletonEncapsulates the running application.In watchOS 2, we have WKExtension

Page 115: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

WKExtensionOpen URLs

WKExtension.sharedExtension().openSystemURL(systemURL)

Valid Schemes• Phone• SMS• PassKit

Page 116: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notifications

Page 117: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Remote Notifications

Page 118: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Remote Notifications

Remote Notification

Page 119: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Remote Notifications

Page 120: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification Routing RulesCriteria include

Page 121: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification Routing RulesCriteria include

iPhone screen is locked

Page 122: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification Routing RulesCriteria include

iPhone screen is locked Watch• on wrist• unlocked

Page 123: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

NotificationsNotification handling when app is not active

Called on WKUserNotificationInterfaceControllerfunc didReceiveRemoteNotification(remoteNotification: [NSObject : AnyObject], withCompletion: WKUserNotificationInterfaceType -> Void) func didReceiveLocalNotification(localNotification: UILocalNotification, withCompletion: WKUserNotificationInterfaceType -> Void)

Page 124: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Local Notifications

Page 125: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Local Notifications

Local Notification

Page 126: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Local Notifications

Page 127: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Scheduling Local NotificationSending message to phone

Page 128: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Scheduling Local NotificationSending message to phone

let message = ["request" : "fireLocalNotification"] WCSession.defaultSession().sendMessage(message, replyHandler: nil, errorHandler: { error in print(error.localizedDescription)     } )

Page 129: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Scheduling Local NotificationSending message to phone

let message = ["request" : "fireLocalNotification"] WCSession.defaultSession().sendMessage(message, replyHandler: nil, errorHandler: { error in print(error.localizedDescription)     } )

func session(session: WCSession, didReceiveMessage message: [String : AnyObject]) {     guard message["request"] as? String == “fireLocalNotification” else { return }

    let localNotification = buildLocalNotification() UIApplication.sharedApplication().scheduleLocalNotification(

localNotification) }

Page 130: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 131: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification ActionsLaunching from a notification action

func handleActionWithIdentifier(identifier: String, forRemoteNotification: [NSObject : AnyObject]) func handleActionWithIdentifier(identifier: String, forLocalNotification: UILocalNotification)

Page 132: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Inline notification text replies

Page 133: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 134: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 135: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification ActionsProviding suggestions for inline text replies

func suggestionsForResponseToActionWithIdentifier(identifier: String, remoteNotification: [String : AnyObject]) -> [String] { return ["Beep!", "Beep! Beep!"] }

Page 136: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification ActionsLaunching from a notification action with inline text input

func handleActionWithIdentifier(identifier: String, forRemoteNotification: [NSObject : AnyObject], withResponseInfo: [NSObject : AnyObject])

func handleActionWithIdentifier(identifier: String, forLocalNotification: UILocalNotification, withResponseInfo: [NSObject : AnyObject])

Page 137: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Notification ActionsLaunching from a notification action with inline text input

func handleActionWithIdentifier(identifier: String, forRemoteNotification: [NSObject : AnyObject], withResponseInfo: [NSObject : AnyObject])

func handleActionWithIdentifier(identifier: String, forLocalNotification: UILocalNotification, withResponseInfo: [NSObject : AnyObject])

Inline text stored inUIUserNotificationActionResponseTypedTextKey

Page 138: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 139: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 140: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 141: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code
Page 142: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

NotificationsNotification handling when app is active

On your WKExtensionDelegate:

func didReceiveRemoteNotification(userInfo: [NSObject : AnyObject]) func didReceiveLocalNotification(notification: UILocalNotification)

Page 143: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Modal Alerts

Page 144: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Modal Alerts

func presentAlertControllerWithTitle(title: String?, message: String?, preferredStyle: WKAlertControllerStyle, actions: [WKAlertAction])

Page 145: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Modal Alert.Alert

Page 146: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Modal Alerts.SideBySideButtonsAlert

Page 147: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Modal Alerts.ActionSheet

Page 148: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Summary

Page 149: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Summary

New architecture in watchOS 2

Page 150: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Summary

New architecture in watchOS 2WKExtensionDelegate

Page 151: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Summary

New architecture in watchOS 2WKExtensionDelegateNew API

Page 152: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Summary

New architecture in watchOS 2WKExtensionDelegateNew APIMore to come…

Page 153: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

More Information

DocumentationwatchOS 2 Transition GuideWatchKit Programmingdeveloper.apple.com/library

Sample CodeListerWatchKit Cataloguedeveloper.apple.com/watchOS

Technical SupportApple Developer ForumsDeveloper Technical Support

General InquiriesJake Behrens, watchOSFrameworks [email protected]

Page 154: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code

Related Sessions

Introducing WatchKit for watchOS 2 Presidio Tuesday 10:00AM

Building Watch Apps Pacific Heights Tuesday 4:30PM

WatchKit In-Depth, Part 2 Pacific Heights Wednesday 10:00AM

Creating Complications with ClockKit Pacific Heights Wednesday 11:00AM

WatchKit Tips and Tricks Presidio Friday 10:00AM

Page 155: WatchKit In-Depth, Part 1 - Apple Inc....Architecture Watch App for watchOS 2 iPhone iOS Application Resources Code Watch App Resources Interface WatchKit Extension Resources Code