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

# runModalPrintOperation(_:delegate:didRun:contextInfo:)

Runs the specified print operation modally.

```
func runModalPrintOperation(_ printOperation: NSPrintOperation, delegate: Any?, didRun didRunSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)
```

## Parameters

`printOperation`

The print operation to run.

`delegate`

The delegate to which the selector message is sent.

`didRunSelector`

The selector of the message sent to the delegate.

`contextInfo`

Object passed with the callback to provide any additional context information.

## Discussion

Overrides of [`printShowingPrintPanel:`](/documentation/AppKit/NSDocument/printShowingPrintPanel:) can invoke this method.

When the panel is dismissed, `delegate` is sent a `didRunSelector` message. Pass the `contextInfo` object with the callback. The `didRunSelector` callback method should have the following signature:

```objc
- (void)documentDidRunModalPrintOperation:(NSDocument *)document  success:(BOOL)success  contextInfo:(void *)contextInfo
```

---

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)