How do I use the new choice API

Asked on 06/13/2025

1 search

To use the new Multiple Choice API, you can follow the guidance provided in the session "Explore new advances in App Intents" from WWDC 2025. The API allows you to present several options for users to choose from, enhancing the user experience by providing alternatives to actions like deletion.

Here's a brief overview of how to implement it:

  1. Present the Multiple Choice Snippet: In the Perform method, you can present the multiple choice snippet by calling the RequestChoice method. You need to provide an array of options using the between parameter.

  2. Customize Options: Options can be created with custom titles, and you can specify a style to tell the system how to render them. You can also customize the snippet with a dialog and a custom SwiftUI view.

  3. Handle User Selection: When an option is picked, it's returned from the RequestChoice method. If the request is canceled, it throws an error that terminates the perform method, and you should not catch this error. Use a switch statement to branch on the chosen option, using the original options as the expected values.

For more detailed information, you can refer to the session Explore new advances in App Intents (15:57).