Using Actions in UI

  • A wrapper for a type-erased user action that has been bound to a particular action runner.

    This provides a way for the owner of the action runner (which may not be a view controller) to provide actions to the view controller that can be performed on their own, without needing access to the action runner. Because they are type-erased, it’s possible to create a heterogenous collection of bound user actions (for showing a menu, for instance) or have a property expose an action whose underlying type is different depending on the state of the app.

    Bound user actions can also be easily converted into various UIKit action types as necessary for different types of UI, like context menus and action sheets.

    To bind a user action to an action runner, creating a BoundUserAction, use UserAction.bind(to:title:options:). It’s also possible to create a BoundUserAction directly from closures in cases where a user action isn’t appropriate for the task.

    See more

    Declaration

    Swift

    public struct BoundUserAction<ResultType>
  • Options that determine how a bound action is displayed in UI.

    See more

    Declaration

    Swift

    public struct BoundUserActionOptions : OptionSet