---
title: "beginSheet(with:modalFor:delegate:didEnd:contextInfo:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nspagelayout/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.

## Declaration

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

Discussion The didEndSelector argument must have the same signature as: - (void)pageLayoutDidEnd:(NSPageLayout *)pageLayout returnCode:(int)returnCode  contextInfo: (void *)contextInfo; The value passed as returnCode is either NSCancelButton or NSOKButton.

## See Also

### Running the page setup dialog

- [beginSheet(using:on:completionHandler:)](appkit/nspagelayout/beginsheet(using:on:completionhandler:).md)
- [runModal()](appkit/nspagelayout/runmodal().md)
- [runModal(with:)](appkit/nspagelayout/runmodal(with:).md)
