Apple Watch API – WKInterfaceController

Table 3-1Key methods of WKInterfaceController

Method

Tasks to perform

init

This method is your first chance to initialize your interface controller.

awakeWithContext:

This method lets you configure the interface controller using any available context data. Use it to load data and update labels, images, tables, and other interface objects in your storyboard scene. The context data is data you provide to assist in the configuration of the new interface controller. For example, when pushing a new interface controller in a hierarchical interface, you specify a context object that contains the next level of data to display. Providing a context object is recommended but not required.

willActivate

This method lets you know that your interface will soon be visible to the user. Use this method only to make small changes to your interface. For example, you might use this method to update a label based on new data. The bulk of your interface initialization should still occur in the init and awakeWithContext: methods.

didDeactivate

Use the didDeactivate method to clean up your interface and put it into a quiescent state. For example, use this method to invalidate timers and stop animations.

You cannot set values for any interface objects from this method. From the time this method is called to the time the willActivate method is called again, any attempts to set values for interface objects are ignored.

Leave a Reply

Your email address will not be published. Required fields are marked *