<!--
{
  "availability" : [
    "macOS: 10.6.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWorkspace/urlForApplication(toOpen:)-7qkzf",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWorkspace(im)URLForApplicationToOpenURL:"
  },
  "title" : "urlForApplication(toOpen:)"
}
-->

# urlForApplication(toOpen:)

Returns the URL to the default app to open the specified URL.

```
func urlForApplication(toOpen url: URL) -> URL?
```

## Parameters

`url`

The URL of the file to open.

## Return Value

The URL of the default app that would open the specified `url`. Returns `nil` if no app can open the URL, or if the file URL does not exist.

## Discussion

This method is the programmatic equivalent of double-clicking a document in the Finder.

You can safely call this method from any thread of your app.

---

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)