getComplicationDescriptors(handler:)
Returns the list of complication descriptors.
Declaration
optional func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void)optional func complicationDescriptors() async -> [CLKComplicationDescriptor]Parameters
- handler:
In your data source’s implementation, call the handler and pass the complication descriptors for your app. This block takes the following parameter:
descriptorsAn array containing your app’s complication descriptors.
Mentioned in
Discussion
ClockKit calls this method to determine the complications that an app supports. Implement this method to define your app’s complications. For example, a weather app may support different complications for the current condition, temperature, or chance of precipitation.
You can also use your implementation to customize the types of complications according to your app’s current data. For example, a weather app could provide separate complications for the user’s favorite locations.
In your data source’s implementation, create an array of CLKComplicationDescriptor objects to represent the complications that your app supports, and then pass the array to the method’s handler.
func getComplicationDescriptors(handler: @escaping ([CLKComplicationDescriptor]) -> Void) {
let mySupportedFamilies = CLKComplicationFamily.allCases
// Create the condition descriptor.
let conditionDescriptor = CLKComplicationDescriptor(
identifier: complicationConditionIdentifier,
displayName: "Weather Condition",
supportedFamilies: mySupportedFamilies)
// Create the temperature descriptor.
let temperatureDescriptor = CLKComplicationDescriptor(
identifier: complicationTemperatureIdentifier,
displayName: "Temperature",
supportedFamilies: mySupportedFamilies)
// Create the precipitation descriptor.
let precipitationDescriptor = CLKComplicationDescriptor(
identifier: complicationPrecipitationIdentifier,
displayName: "Percipitation",
supportedFamilies: mySupportedFamilies)
// Call the handler and pass an array of descriptors.
handler([conditionDescriptor,
temperatureDescriptor,
precipitationDescriptor])
}In addition to defining a unique type of complication, each descriptor also defines the families that the complication supports. Each descriptor appears as a separate complication on the Apple Watch’s face customization screen.
The complications appear in the same order as the descriptor array. When the user configures a complication, the picker shows the first three items from the array that support the complication’s family. If there are more than three, the picker displays a More button to provide access to the additional complications.
To update the descriptors, call reloadComplicationDescriptors().
See Also
Deprecated methods
CLKLaunchedTimelineEntryDateKeyCLKLaunchedComplicationIdentifierKeyhandleSharedComplicationDescriptors(_:)getLocalizableSampleTemplate(for:withHandler:)getPrivacyBehavior(for:withHandler:)CLKComplicationPrivacyBehaviorgetAlwaysOnTemplate(for:withHandler:)getTimelineEndDate(for:withHandler:)getCurrentTimelineEntry(for:withHandler:)getTimelineEntries(for:after:limit:withHandler:)getTimelineAnimationBehavior(for:withHandler:)CLKComplicationTimelineAnimationBehaviorgetSupportedTimeTravelDirections(for:withHandler:)CLKComplicationTimeTravelDirectionsgetTimelineStartDate(for:withHandler:)