Protocol

WKInterfaceObjectRepresentable

A view that represents a WatchKit interface object.

Declaration

protocol WKInterfaceObjectRepresentable where Self.Body == Never

Overview

In the lifetime of a representable view, SwiftUI initializes a WKInterfaceObject and Coordinator, updates them (often repeatedly), and eventually deinitializes them.

For each phase, SwiftUI calls the following methods in order:

// Initialization phase:
makeCoordinator()
makeWKInterfaceObject(context:)
updateWKInterfaceObject(_:context:)

// Update phase:
updateWKInterfaceObject(_:context:)

// Deinitialization phase:
dismantleWKInterfaceObject(_:coordinator:)

Topics

Associated Types

associatedtype Coordinator

A type to coordinate with the WatchKit interface object.

Required.

associatedtype WKInterfaceObjectType

The type of WatchKit interface object to be presented.

Required.

Instance Methods

func makeCoordinator() -> Self.Coordinator

Creates a coordinator instance to coordinate with the interface object.

Required. Default implementation provided.

func makeWKInterfaceObject(context: Self.Context) -> Self.WKInterfaceObjectType

Creates a WatchKit interface object to be presented.

Required.

func updateWKInterfaceObject(Self.WKInterfaceObjectType, context: Self.Context)

Updates the presented WatchKit interface object (and its coordinator) to the latest configuration.

Required.

Type Methods

static func dismantleWKInterfaceObject(Self.WKInterfaceObjectType, coordinator: Self.Coordinator)

Cleans up the presented WatchKit interface object (and its coordinator) in anticipation of their removal.

Required. Default implementation provided.

Relationships

Inherits From

See Also

WatchKit Hosting

class WKHostingController

A WatchKit interface controller which hosts a SwiftUI view hierarchy.

class WKUserNotificationHostingController

A WatchKit user notification interface controller which hosts a SwiftUI view hierarchy.

struct WKInterfaceObjectRepresentableContext

The context in which updates to an associated WatchKit interface object take place.

enum DigitalCrownRotationalSensitivity

The amount of Digital Crown rotation needed to move between two integer numbers.