<!--
{
  "availability" : [
    "macOS: 10.0.0 - 27.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSPageLayout/beginSheet(with:modalFor:delegate:didEnd:contextInfo:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSPageLayout(im)beginSheetWithPrintInfo:modalForWindow:delegate:didEndSelector:contextInfo:"
  },
  "title" : "beginSheet(with:modalFor:delegate:didEnd:contextInfo:)"
}
-->

# beginSheet(with:modalFor:delegate:didEnd:contextInfo:)

Presents a page setup sheet for the specified print info object, document-modal relative to the specified window.

```
func beginSheet(with printInfo: NSPrintInfo, modalFor docWindow: NSWindow, delegate: Any?, didEnd didEndSelector: Selector?, contextInfo: UnsafeMutableRawPointer?)
```

## Parameters

`printInfo`

The `NSPrintInfo` object to use.

`docWindow`

The window to which the sheet is attached.

`delegate`

The delegate to which `didEndSelector` is sent. Can be `nil`.

`didEndSelector`

The selector sent to the delegate. Can be `nil`.

`contextInfo`

Context information object passed with `didEndSelector`.

## Discussion

The `didEndSelector` argument must have the same signature as:

```objc
- (void)pageLayoutDidEnd:(NSPageLayout *)pageLayout returnCode:(int)returnCode  contextInfo: (void *)contextInfo;
```

The value passed as `returnCode` is either `NSCancelButton` or `NSOKButton`.

---

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)