TargetAction

open class TargetAction

The TargetAction class bridges the gap between Swift closures and the common Cocoa target (id)/action (SEL) paradigm. Construct a TargetAction with a no-argument or single-argument callback closure. Then, use the target and action properties of the TargetAction instance as you would normally anywhere Cocoa calls for a target/action.

  • The object to use as the target of a target/action pair.

    Declaration

    Swift

    open var target: Any
  • The Selector to use as the action of the target/action pair.

    Declaration

    Swift

    open var action: Selector
  • Constructs a TargetAction with a no-argument callback.

    Declaration

    Swift

    public init(callback: @escaping () -> Void)

    Parameters

    callback

    A callback closure that will be executed when the target/action pair represented by the newly-constructed instance is invoked.

  • Constructs a TargetAction with a single-argument callback.

    Declaration

    Swift

    public init(callback: @escaping (Any?) -> Void)

    Parameters

    callback

    A callback closure that will be executed when the target/action pair represented by the newly-constructed instance is invoked. The Any? argument passed to callback will be the argument sent to action when invoked.