Shortcut

public protocol Shortcut

A type that represents a user workflow, or a part of one, in the Shortcuts app.

  • The type of shortcut representing the body of this shortcut.

    When you create a custom shortcut, Swift infers this type from your implementation of the required body property.

    Declaration

    Swift

    associatedtype Body : Shortcut
  • The contents of the shortcut.

    Declaration

    Swift

    var body: Body { get }
  • usingResult(named:uuid:in:) Extension method

    Passes the output of this shortcut as a variable that can be referenced in other shortcuts.

    Declaration

    Swift

    public func usingResult<Content>(named name: String? = nil, uuid: UUID = UUID(), @ShortcutBuilder in builder: (Variable) -> Content) -> ResultShortcut<Self, Content> where Content : Shortcut

    Parameters

    name

    An optional name to use for the new variable.

    uuid

    An optional UUID to use for the new variable. Useful for building deterministic output.

    builder

    A closure that is passed the result of the modified shortcut.

    Return Value

    A modified shortcut that passes its result to the builder closure.

  • savingOutput(to:) Extension method

    Saves the output of this shortcut into an output variable that can be referenced in other shortcuts.

    Declaration

    Swift

    public func savingOutput(to outputVariable: OutputVariable) -> SavedOutputShortcut<Self>

    Parameters

    outputVariable

    An OutputVariable into which the result of this Shortcut will be saved.

    Return Value

    A modified shortcut that saves the result into an output variable.

  • build() Extension method

    Serializes the body of the Shortcut to a file format suitable for opening in the Shortcuts app.

    Throws

    An error of type EncodingError, if one is thrown during the encoding process.

    Declaration

    Swift

    public func build() throws -> Data

    Return Value

    The binary data representing this Shortcut.