<!--
{
  "availability" : [
    "macOS: 10.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SecurityInterface",
  "identifier" : "/documentation/SecurityInterface/SFCertificatePanel/beginSheet(for:modalDelegate:didEnd:contextInfo:certificates:showGroup:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Security Interface"
    ],
    "preciseIdentifier" : "c:objc(cs)SFCertificatePanel(im)beginSheetForWindow:modalDelegate:didEndSelector:contextInfo:certificates:showGroup:"
  },
  "title" : "beginSheet(for:modalDelegate:didEnd:contextInfo:certificates:showGroup:)"
}
-->

# beginSheet(for:modalDelegate:didEnd:contextInfo:certificates:showGroup:)

Displays one or more certificates in a modal sheet.

```
func beginSheet(for docWindow: NSWindow!, modalDelegate delegate: Any!, didEnd didEndSelector: Selector!, contextInfo: UnsafeMutableRawPointer!, certificates: [Any]!, showGroup: Bool)
```

## Parameters

`docWindow`

The parent window to which the sheet is attached.

`delegate`

The delegate object in which the method specified in the `didEndSelector` parameter is implemented.

`didEndSelector`

A selector for a delegate method called when the sheet has been dismissed. Implementation of this delegate method is optional.

`contextInfo`

A pointer to data that is passed to the delegate method. You can use this data pointer for any purpose you wish.

`certificates`

The certificates to display. Pass an <doc://com.apple.documentation/documentation/Foundation/NSArray> containing one or more objects of type <doc://com.apple.documentation/documentation/Security/SecCertificate> in this parameter. The first certificate in the array must be the leaf certificate. The other certificates (if any) can be included in any order.

`showGroup`

Specifies whether additional certificates (other than the leaf certificate) are displayed.

## Discussion

The behavior of this method is somewhat different in macOS 10.4 and later versus OS X v10.3. In OS X v10.3, the sheet displays whatever certificates you pass in the `certificates` parameter (provided the `showGroup` parameter is set to <doc://com.apple.documentation/documentation/Swift/true>). Starting with OS X v10.4, the sheet displays the leaf certificate (that is, the first certificate in the array you pass) plus any other certificates in the certificate chain that the Security Server can find. If you include all of the certificates in the chain in the `certificates` parameter, you can ensure that the same certificates are displayed whatever the version of the operating system, and may decrease the time required to find and display the certificates in macOS 10.4 and later.

The delegate method has the following signature:

```objc
- (void)certificateSheetDidEnd:(NSWindow *)sheet
        returnCode:(NSInteger)returnCode
        contextInfo:(void *)contextInfo
```

The parameters for the delegate method are:

- `sheet`: The window to which the sheet was attached.
- `returnCode`: The result code indicating which button the user clicked: either <doc://com.apple.documentation/documentation/AppKit/NSFileHandlingPanelOKButton> or <doc://com.apple.documentation/documentation/AppKit/NSFileHandlingPanelCancelButton>.
- `contextInfo`: Client-defined contextual data that is passed in the `contextInfo` parameter of the `beginSheetForDirectory:...` method.

The delegate method may dismiss the keychain settings sheet itself; if it does not, the sheet is dismissed on return from the `beginSheetForDirectory:...` method.

---

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)