<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/setDefaultApplication(at:toOpen:completion:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)setDefaultApplicationAtURL:toOpenContentType:completionHandler:"
  },
  "title" : "setDefaultApplication(at:toOpen:completion:)"
}
-->

# setDefaultApplication(at:toOpen:completion:)

Sets the default app to use when opening files of a specific content type.

```
func setDefaultApplication(at applicationURL: URL, toOpen contentType: UTType, completion completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`applicationURL`

The URL of the default application.

`contentType`

The content type to open.

`completionHandler`

The completion handler to call after the operation completes.

## Discussion

This method sets the default app to open for files of the specified `contentType`. If a change requires user consent, the system asks the user for consent asynchronously before invoking the completion handler.

---

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)