perform(with:completionHandler:)
Performs the action associated with the command using the information in an invocation.
Declaration
func perform(with invocation: XCSourceEditorCommandInvocation, completionHandler: @escaping @Sendable ((any Error)?) -> Void)func perform(with invocation: XCSourceEditorCommandInvocation) async throwsParameters
- invocation:
The invocation of the command to be invoked.
- completionHandler:
A block to be executed when the command finishes.
Mentioned in
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.