Instance Method

perform(with:completionHandler:)

Performs the action associated with the command using the information in an invocation.

Required.

Declaration

func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping (Error?) -> Void)

Parameters

invocation

The invocation of the command to be invoked.

completionHandler

A block to be executed when the command finishes.

Discussion

Xcode passes the code a completion handler that it must invoke to finish performing the command, passing nil on success or an error on failure. A canceled command must still call the completion handler, passing nil.

There are no guarantees about the thread or queue on which the cancellation handler is invoked.