An interface for configuring a Control Center module.
The parameters of your intent define all of the configuration options
for your control.
```swift
struct SelectFocusIntent: ControlConfigurationIntent {
static let title: LocalizedStringResource = "Select Focus"
static let description: IntentDescription = "Turn Focus on to silence notifications and filter out distractions."
struct FocusOptionsProvider: DynamicOptionsProvider {
func results() async throws -> [Focus] {
FocusManager.shared.allFocuses
}
}
@Parameter(title: "Focus", default: .doNotDisturb, optionsProvider: FocusOptionsProvider())
var focus: Focus
}
```
When using this protocol, you don't need to provide an implementation
for ``AppIntent/perform()``. You can, however, still implement `perform()` to
use the same implementation for both control configuration and as an actionable
intent.
The example above provides a default value for the `focus` intent parameter. By providing a default value,
you can use a non-optional value for the intent parameter. If you don't provide a default value for the intent parameter,
the parameter's value must be optional, to allow the system to preview the control before someone configures it.
Members (1)
method · iOS 18.0+
perform
Swift declaration
func perform() async throws -> Self.NeverResult
A default implementation that throws an error rather than perform an intent.
You don't need to implement ``perform()`` on your ``ControlConfigurationIntent`` to use it for
configuring a control. However, you may implement it if you also use this intent for widget configuration
or as a runnable action.