<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenSavePanelDelegate/panel(_:userEnteredFilename:confirmed:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSOpenSavePanelDelegate(im)panel:userEnteredFilename:confirmed:"
  },
  "title" : "panel(_:userEnteredFilename:confirmed:)"
}
-->

# panel(_:userEnteredFilename:confirmed:)

Tells the delegate that the user confirmed a filename choice by clicking Save in a Save panel.

```
@MainActor optional func panel(_ sender: Any, userEnteredFilename filename: String, confirmed okFlag: Bool) -> String?
```

## Parameters

`sender`

The panel that reports the user’s confirmation of a filename choice.

`filename`

The user’s filename choice.

`okFlag`

If <doc://com.apple.documentation/documentation/Swift/true>, the user clicked the Save button; if <doc://com.apple.documentation/documentation/Swift/false>, the user did not.

## Return Value

The filename selected by the user, or `nil` if you want to cancel the save operation and leave the Save panel onscreen.

## Discussion

The Save panel calls this method before appending any required filename extension information, and before it asks the user whether to replace an existing file, if a file with the specified name already exists in the given location.

The panel may call this method multiple times as the user types. When it does, the `okFlag` parameter is <doc://com.apple.documentation/documentation/Swift/false>. When the use confirms their choice, the value in the `okFlag` is <doc://com.apple.documentation/documentation/Swift/true>. If your delegate does extensive validation or puts up alerts, do so only when `okFlag` is <doc://com.apple.documentation/documentation/Swift/true>.

In macOS 10.15 and later, you cannot change the filename that the user selects. Prior to macOS 10.15, you could sanitize the app’s filename to remove undesirable characters or limit its length only if your app wasn’t running in a sandbox.

## See Also

[`panel(_:validate:)`](/documentation/AppKit/NSOpenSavePanelDelegate/panel(_:validate:))

Asks the delegate to validate the URL for a file that the user selected.



---

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)