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

# setDefaultApplication(at:toOpenURLsWithScheme:completion:)

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

```
func setDefaultApplication(at applicationURL: URL, toOpenURLsWithScheme urlScheme: String, completion completionHandler: (@Sendable ((any Error)?) -> Void)? = nil)
```

## Parameters

`applicationURL`

The URL of the default application.

`urlScheme`

The URL of the scheme to open.

`completionHandler`

The completion handler to call after the operation completes.

## Discussion

This method sets the default app to open files of the type specified by the `urlScheme`. If a change requires user consent, the system asks the 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)