UAAction

@interface UAAction : NSObject

Base class for actions, 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

  • 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

    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

    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.

  • 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, completionHandler: @escaping UAActionCompletionHandler)

    Parameters

    arguments

    A UAActionArguments value representing the arguments passed to the action.

    completionHandler

    A UAActionCompletionHandler that will be called when the action has finished executing.

  • Factory method for creating anonymous actions

    Declaration

    Objective-C

    + (nonnull instancetype)actionWithBlock:(nonnull UAActionBlock)actionBlock;

    Swift

    convenience init(block actionBlock: @escaping UAActionBlock)

    Parameters

    actionBlock

    A UAActionBlock representing the primary work performed by the action.

  • Factory method for creating anonymous actions

    Declaration

    Objective-C

    + (nonnull instancetype)actionWithBlock:(nonnull UAActionBlock)actionBlock
                         acceptingArguments:
                             (nullable UAActionPredicate)predicateBlock;

    Swift

    convenience init(block actionBlock: @escaping UAActionBlock, acceptingArguments predicateBlock: UAActionPredicate? = nil)

    Parameters

    actionBlock

    A UAActionBlock representing the primary work performed by the action.

    predicateBlock

    A UAActionPredicate limiting the scope of the arguments.