<!--
{
  "availability" : [
    "iOS: 2.0.0 - 9.0.0",
    "iPadOS: 2.0.0 - 9.0.0",
    "macCatalyst: 13.1.0 - 13.1.0",
    "macOS: 10.0.0 - 10.11.0",
    "tvOS: 9.0.0 - 9.0.0",
    "visionOS: 1.0.0 - 1.0.0",
    "watchOS: 2.0.0 - 2.0.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURL/init(scheme:host:path:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURL(im)initWithScheme:host:path:"
  },
  "title" : "init(scheme:host:path:)"
}
-->

# init(scheme:host:path:)

Initializes a newly created NSURL with a specified scheme, host, and path.

```
convenience init?(scheme: String, host: String?, path: String)
```

## Parameters

`scheme`

The scheme for the NSURL object. For example, in the URL `http://www.example.com/index.html`, the scheme is `http`.

`host`

The host for the NSURL object (for example, `www.example.com`). May be the empty string.

`path`

The path for the NSURL object (for example, `/index.html`). If the path begins with a tilde, you must first expand it by calling [`expandingTildeInPath`](/documentation/Foundation/NSString/expandingTildeInPath).

## Return Value

The newly initialized NSURL object.

## Discussion

This method automatically uses percent encoding to escape the `path` and `host` parameters.

## See Also

  [File System Programming Guide](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010672)

[URL Loading System](/documentation/Foundation/url-loading-system)

Interact with URLs and communicate with servers using standard Internet protocols.



---

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)