---
title: "runModal(for:delegate:didRun:contextInfo:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsprintoperation/runmodal(for:delegate:didrun:contextinfo:)"
---

# runModal(for:delegate:didRun:contextInfo:)

Runs the print operation, calling your custom delegate method upon completion.

## Declaration

```swift
func runModal(for docWindow: NSWindow, delegate: Any?, didRun didRunSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)
```

## Parameters

- `docWindow`: The document window to receive a print progress sheet.
- `delegate`: The printing delegate object. Messages are sent to this object.
- `didRunSelector`: The delegate method called after the completion of the print operation.
- `contextInfo`: A pointer to any data you want passed to the method in the didRunSelector parameter.

## Discussion

Discussion The method specified by the  didRunSelector parameter must have the following signature: - (void)printOperationDidRun:(NSPrintOperation *)printOperation  success:(BOOL)success  contextInfo:(void *)contextInfo The value of success is true if the print operation ran to completion without cancellation or error, and false otherwise. If you send canSpawnSeparateThread to an NSPrintOperation object with an argument of true, then the delegate specified in a subsequent invocation of runModal(for:delegate:didRun:contextInfo:) may be messaged in that spawned, non-main thread.

## See Also

### Running the Print Operation

- [run()](appkit/nsprintoperation/run().md)
- [cleanUp()](appkit/nsprintoperation/cleanup().md)
- [deliverResult()](appkit/nsprintoperation/deliverresult().md)
