iOS development: The WatchKit Application essentials

Source: Internet
Author: User
Tags home screen

WatchKit Application Architecture

The WatchKit application is an executable file that runs in Apple Watch. It includes the resource files required to storyboard and render the screen.

The WatchKit extension is the executable file that runs on the IPhone. This includes managing the logical code for the application interface and handling user interactions.

For the normal use of the program interface, the two parts need to be run together. Typical steps for user interaction with an application are as follows:

The user interacts with the WatchKit application.

The WatchKit application analyzes the interaction and selects the storyboard that will be managed.

WatchKit communicates with the IPhone to run WatchKit extensions.

WatchKit extension initialization and creates objects that need to be supplied to the WatchKit application storyboard.

Storyboard generates scene based on the object created by the WatchKit extension and displays it to the Apple Watch.

WatchKit applications and WatchKit will share some information until the user stops using the WatchKit application. At this point, IOS will allow WatchKit to extend hibernation until new user interaction is available.

The following diagram illustrates this process:

An important concept in the above diagram is the way storyboard responds to user actions and configures the screen content that needs to be displayed. This is thanks to the interface controller object (Wkinterfacecontroller instance), which is equivalent to view controller in IOS.

Unlike view controller, interface controller does not manage the actual view,watchkit in the screen to handle the view transparently. In general, a WatchKit application will have multiple interface controller that display different data types, but only one at a time.

The lifecycle of the WatchKit application

There are 3 ways to start a WatchKit application:

The user clicks on the icon on the Apple Watch home screen.

The user interacts with the glance of the application.

The user interacts with the notification.

Each of the above methods initializes the WatchKit application and the WatchKit extension. Depending on the different boot methods above, WatchKit will load the scene with the appropriate storyboard and request WatchKit to initialize the corresponding interface controller.

The following illustration shows the related process:

As shown in the figure, the interface controller object manages related interactions in the user interface. The WatchKit extension runs when the user interacts with an application on the Apple Watch. Once the user stops interacting or exits from the program, IOS closes the current interface controller and sleeps the extension. This interaction is very concise between the user and Apple Watch, and the interface controller should be lightweight and perform tasks quickly.

The following illustration shows the related process:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.