<!--
{
  "availability" : [
    "macCatalyst: -",
    "macOS: 10.0.0 - 10.6.0"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSOpenPanel/beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSOpenPanel(im)beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:"
  },
  "title" : "beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:"
}
-->

# beginForDirectory:file:types:modelessDelegate:didEndSelector:contextInfo:

Presents a modeless Open panel.

```
- (void) beginForDirectory:(NSString *) path file:(NSString *) name types:(NSArray *) fileTypes modelessDelegate:(id) delegate didEndSelector:(SEL) didEndSelector contextInfo:(void *) contextInfo;
```

## Parameters

`path`

The directory whose files the panel displays. When `nil`, the directory is the same directory used in the previous invocation of the panel; this is probably the best choice for most situations.

`name`

Specifies a particular file in `absoluteDirectoryPath` that is selected when the Open panel is presented to the user. When `nil`, no file is initially selected.

`fileTypes`

An array of file extensions and/or HFS file types. Specifies the files the panel allows the user to select. `nil` makes all files in `absoluteDirectoryPath` selectable by the user. An array of types passed in here will override one set using [`allowedFileTypes`](/documentation/AppKit/NSSavePanel/allowedFileTypes).

`delegate`

This is not the same as a delegate assigned to the panel. This delegate is temporary and the relationship only lasts until the panel is dismissed.

`didEndSelector`

The message sent to `modelessDelegate` after the panel’s session has ended, but before dismissing the Open panel. `didEndSelector` may dismiss the Open panel itself; otherwise, it will be dismissed on return from the method. The corresponding method should have the following signature:

```objc
- (void)openPanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode  contextInfo:(void  *)contextInfo
```

    The value passed as     `returnCode`     will be either     `NSCancelButton`     or     `NSOKButton`    .

`contextInfo`

Any context information passed to `modelessDelegate` in the `didEndSelector` message.

## Discussion

Similar to [`beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:`](/documentation/AppKit/NSOpenPanel/beginSheetForDirectory:file:types:modalForWindow:modalDelegate:didEndSelector:contextInfo:), but allows for modeless operation of the panel.

## See Also

[`func begin(completionHandler: (NSApplication.ModalResponse) -> Void)`](/documentation/AppKit/NSSavePanel/begin(completionHandler:))

Presents the panel as a modeless window.



---

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)