---
title: "setDefaultApplication(at:toOpenFileAt:completion:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsworkspace/setdefaultapplication(at:toopenfileat:completion:)"
---

# setDefaultApplication(at:toOpenFileAt:completion:)

Sets the default app to use when opening a specific file.

## Declaration

```swift
func setDefaultApplication(at applicationURL: URL, toOpenFileAt url: URL, completion completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

```swift
func setDefaultApplication(at applicationURL: URL, toOpenFileAt url: URL) async throws
```

## Parameters

- `applicationURL`: The URL of the default app to use when opening the file.
- `url`: The URL of the file to open.
- `completionHandler`: The completion handler to call after the operation completes.

## Discussion

Discussion This method sets the default app to use for a specific file (rather than all files of that content type). The system requires write access to the specified url before it can make the change. If a change requires user consent, the system asks the user for consent asynchronously before invoking the completion handler. This function doesn’t apply to non-file URLs.

## See Also

### Setting Default Application Information

- [setDefaultApplication(at:toOpen:completion:)](appkit/nsworkspace/setdefaultapplication(at:toopen:completion:).md)
- [setDefaultApplication(at:toOpenContentTypeOfFileAt:completion:)](appkit/nsworkspace/setdefaultapplication(at:toopencontenttypeoffileat:completion:).md)
- [setDefaultApplication(at:toOpenURLsWithScheme:completion:)](appkit/nsworkspace/setdefaultapplication(at:toopenurlswithscheme:completion:).md)
