Protocol

HMHomeManagerDelegate

An interface the home manager uses to communicate changes to the state of the home network.

Declaration

protocol HMHomeManagerDelegate

Overview

Adopt this protocol to find out about changes made outside your app to the set of homes in the HomeKit database, like when homes are added or removed by another app. You also rely on this protocol when you first create an HMHomeManager instance. The home manager calls the homeManagerDidUpdateHomes(_:) method to indicate that it has finished its initial load of data from the HomeKit database.

Changes that your app initiates—even those made asynchronously followed by a call to a completion handler—generate delegate callbacks in other apps, but not in your own. As a result, your app must update its internal data store or user interface from both the completion handler of an asynchronous call, and the delegate callback that corresponds to the same kind of change made by another app.

To be alerted about changes made within a particular home, adopt the HMHomeDelegate protocol. To find out about changes made to specific accessories, adopt the HMAccessoryDelegate protocol.

Topics

Monitoring Home Manager State Changes

func homeManagerDidUpdateHomes(HMHomeManager)

Tells the delegate that the home manager updated its collection of homes.

func homeManager(HMHomeManager, didAdd: HMHome)

Tells the delegate that the home manager added a home.

func homeManager(HMHomeManager, didRemove: HMHome)

Tells the delegate that the home manager removed a home.

func homeManagerDidUpdatePrimaryHome(HMHomeManager)

Tells the delegate that the home manager updated its primary home.

Relationships

Inherits From

See Also

Keeping Track of Connected Homes

var delegate: HMHomeManagerDelegate?

A delegate that receives updates on the collection of homes.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software