<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPrintOperation/runModal(for:delegate:didRun:contextInfo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPrintOperation(im)runOperationModalForWindow:delegate:didRunSelector:contextInfo:"
  },
  "title" : "runModal(for:delegate:didRun:contextInfo:)"
}
-->

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

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

```
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

The method specified by the  `didRunSelector` parameter must have the following signature:

```objc
- (void)printOperationDidRun:(NSPrintOperation *)printOperation  success:(BOOL)success  contextInfo:(void *)contextInfo
```

The value of `success` is <doc://com.apple.documentation/documentation/Swift/true> if the print operation ran to completion without cancellation or error, and <doc://com.apple.documentation/documentation/Swift/false> otherwise.

If you send [`canSpawnSeparateThread`](/documentation/AppKit/NSPrintOperation/canSpawnSeparateThread) to an `NSPrintOperation` object with an argument of <doc://com.apple.documentation/documentation/Swift/true>, then the delegate specified in a subsequent invocation of [`runModal(for:delegate:didRun:contextInfo:)`](/documentation/AppKit/NSPrintOperation/runModal(for:delegate:didRun:contextInfo:)) may be messaged in that spawned, non-main thread.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)