<!--
{
  "availability" : [
    "macOS: 10.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SecurityInterface",
  "identifier" : "/documentation/SecurityInterface/SFKeychainSavePanel/runModal(forDirectory:file:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Security Interface"
    ],
    "preciseIdentifier" : "c:objc(cs)SFKeychainSavePanel(im)runModalForDirectory:file:"
  },
  "title" : "runModal(forDirectory:file:)"
}
-->

# runModal(forDirectory:file:)

Displays a panel that allows a user to create a new keychain.

```
func runModal(forDirectory path: String!, file name: String!) -> Int
```

## Parameters

`path`

The path to the folder where the keychain is created. Specify `nil` for `~/Library/Keychains`.

`name`

The keychain name to be automatically displayed in the Save As field of the panel.

## Discussion

This method returns a result code from the <doc://com.apple.documentation/documentation/AppKit/NSOpenPanel/runModalForDirectory:file:types:> method of the <doc://com.apple.documentation/documentation/AppKit/NSSavePanel> class: <doc://com.apple.documentation/documentation/AppKit/NSFileHandlingPanelOKButton> if the user clicks the OK button or <doc://com.apple.documentation/documentation/AppKit/NSFileHandlingPanelCancelButton> if the user clicks the Cancel button.

Use the [`keychain()`](/documentation/SecurityInterface/SFKeychainSavePanel/keychain()) method to obtain the keychain created by the user.

## See Also

  <doc://com.apple.documentation/documentation/AppKit/NSOpenPanel/runModalForDirectory:file:types:>



---

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)