---
title: "init(url:resolvingAgainstBaseURL:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/nsurlcomponents/init(url:resolvingagainstbaseurl:)-3bbte"
---

# init(url:resolvingAgainstBaseURL:)

Creates a URL components object by parsing the URL from an NSURL object.

## Declaration

```swift
init?(url: URL, resolvingAgainstBaseURL resolve: Bool)
```

## Parameters

- `url`: The URL to parse.
- `resolve`: Controls whether the URL should be resolved against its base URL before parsing. If doc://com.apple.documentation/documentation/Swift/true, and if the url parameter contains a relative URL, the original URL is resolved against its base URL before parsing by calling the doc://com.apple.foundation/documentation/Foundation/NSURL/absoluteURL method. Otherwise, the string portion is used by itself.

## Return Value

Return Value Returns the initialized URL components object, or nil if the URL could not be parsed.

## See Also

### Creating URL components

- [init()](foundation/nsurlcomponents/init().md)
- [init(string:)](foundation/nsurlcomponents/init(string:).md)
- [init(string:encodingInvalidCharacters:)](foundation/nsurlcomponents/init(string:encodinginvalidcharacters:).md)
