Generic Class


A WatchKit interface controller that hosts a SwiftUI view hierarchy.


class WKHostingController<Body> : WKInterfaceController where Body : View


A WKHostingController presents and manages your app's main interface using SwiftUI views. You must subclass WKHostingController and override the body property to provide the set of SwiftUI views you want to display. Display the content of your hosting controller as you would any other WKInterfaceController object. For example, you can include it as one of your app's root interface controllers, or present it modally.


Creating a Hosting Controller Object


Creates a hosting controller object that you can use to implement your app's main interface using SwiftUI views

Getting the Root View

var body: Body

The root view of the view hierarchy to display for your interface controller.

Updating the Root View

func updateBodyIfNeeded()

Updates the interface controller's set of views immediately, if updates are pending.

func setNeedsBodyUpdate()

Invalidates the current SwiftUI views and triggers an update during the next cycle.

Presenting the Interface Controller

func presentController(withNamesAndContexts: [(name: String, context: AnyObject)])

Presents one or more new interface controllers modally using a page-based arrangement.

class func reloadRootControllers(withNamesAndContexts: [(name: String, context: AnyObject)])

Loads the specified interface controllers and rebuilds the app's page-based interface.

Comparing Interface Controllers

static func == (NSObject, NSObject) -> Bool

Returns a Boolean value indicating whether two values are equal.

static func != (WKHostingController<Body>, WKHostingController<Body>) -> Bool

Returns a Boolean value indicating whether the two objects are not equivalent.

Getting Hash Information

var hashValue: Int

The hash value.

func hash(into: inout Hasher)

Hashes the essential components of this value by feeding them into the given hasher.


Conforms To

See Also

WatchKit Hosting

class WKUserNotificationHostingController

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

protocol WKInterfaceObjectRepresentable

A view that represents a WatchKit interface object.

enum DigitalCrownRotationalSensitivity

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