UAAction

Objective-C

@protocol UAAction <NSObject>

Swift

protocol Action : NSObjectProtocol

Action protocol, which defines a modular unit of work.

  • Called before an action is performed to determine if the the action can accept the arguments.

    This method can be used both to verify that an argument’s value is an appropriate type, as well as to limit the scope of execution of a desired range of values. Rejecting arguments will result in the action not being performed when it is run.

    Declaration

    Objective-C

    - (BOOL)acceptsArguments:(nonnull UAActionArguments *)arguments;

    Swift

    func acceptsArguments(_ arguments: UAActionArguments) -> Bool

    Parameters

    arguments

    A UAActionArguments value representing the arguments passed to the action.

    Return Value

    YES if the action can perform with the arguments, otherwise NO

  • Performs the action.

    Subclasses of UAAction should override this method to define custom behavior.

    Note

    You should not ordinarily call this method directly. Instead, use the UAActionRunner.

    Declaration

    Objective-C

    - (void)performWithArguments:(nonnull UAActionArguments *)arguments
               completionHandler:
                   (nonnull UAActionCompletionHandler)completionHandler;

    Swift

    func perform(with arguments: UAActionArguments) async -> UAActionResult

    Parameters

    arguments

    A UAActionArguments value representing the arguments passed to the action.

    completionHandler

    A completion handler.

  • Called before the action’s performWithArguments:withCompletionHandler:

    This method can be used to define optional setup or pre-execution logic.

    Declaration

    Objective-C

    - (void)willPerformWithArguments:(nonnull UAActionArguments *)arguments;

    Swift

    optional func willPerform(with arguments: UAActionArguments)

    Parameters

    arguments

    A UAActionArguments value representing the arguments passed to the action.

  • Called after the action has performed, before its final completion handler is called.

    This method can be used to define optional teardown or post-execution logic.

    Declaration

    Objective-C

    - (void)didPerformWithArguments:(nonnull UAActionArguments *)arguments
                         withResult:(nonnull UAActionResult *)result;

    Swift

    optional func didPerform(with arguments: UAActionArguments, with result: UAActionResult)

    Parameters

    arguments

    A UAActionArguments value representing the arguments passed to the action.

    result

    A UAActionResult from performing the action.