One Logo Pool Ball
AppIntents · IOS API REFERENCE

DynamicOptionsProvider

protocol · iOS 16.0+ · SDK 27.1

protocol DynamicOptionsProvider : _SupportsAppDependencies

An interface for providing a dynamic list of options for a parameter of your app intent. Implement this protocol in a type that provides a set of possible values for an intent parameter. When configuring the parameter, specify your custom type as the options provider for that parameter. The type of result you return determines how the system displays the information. * Return an array of ``DisplayRepresentable`` types to display a list of values. * Return an array of ``IntentItem`` types to divide values into sections or configure other presentation options. The following example shows the configuration of a custom parameter that contains the author name of a book. The options provider offers two possible suggestions for the author name. For brevity, it omits the rest of the implementation. ```swift struct CreateBook: AppIntent { @Parameter(title: "Author Name", optionsProvider: AuthorNamesOptionsProvider()) var authorName: String // Other properties and the perform() implementation. private struct AuthorNamesOptionsProvider: DynamicOptionsProvider { func results() async throws -> [String] { ["Juan Chavez", "Anne Johnson"] } } } ```

Members (1)

method · iOS 16.0+

defaultResult

Swift declaration
func defaultResult() async -> Self.DefaultValue?

The default value for parameters using this provider when no value is provided by the user. Either a single value or an array of values may be provided. If an array is provided and the parameter requires a single value, only the first element of the array is used.

Skipped declarations

No declarations were skipped in this snapshot.

All AppIntents types →