<!--
{
  "availability" : [
    "iOS: 7.0.0 -",
    "iPadOS: 7.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.9.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/NSURLComponents/componentsWithURL:resolvingAgainstBaseURL:",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSURLComponents(cm)componentsWithURL:resolvingAgainstBaseURL:"
  },
  "title" : "componentsWithURL:resolvingAgainstBaseURL:"
}
-->

# componentsWithURL:resolvingAgainstBaseURL:

Returns a URL components object by parsing the URL from an `NSURL` object.

```
+ (instancetype) componentsWithURL:(NSURL *) url resolvingAgainstBaseURL:(BOOL) resolve;
```

## 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 [`absoluteURL`](/documentation/Foundation/NSURL/absoluteURL) method. Otherwise, the string portion is used by itself.

## Return Value

Returns the new URL components object, or `nil` if the URL could not be parsed.

---

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)