---
title: "componentsWithURL:resolvingAgainstBaseURL:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsurlcomponents/componentswithurl:resolvingagainstbaseurl:"
---

# componentsWithURL:resolvingAgainstBaseURL:

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

## Declaration

```occ
+ (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 doc://com.apple.foundation/documentation/Foundation/NSURL/absoluteURL method. Otherwise, the string portion is used by itself.

## Return Value

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

## See Also

### Creating URL components

- [componentsWithString:](foundation/nsurlcomponents/componentswithstring:.md)
- [componentsWithString:encodingInvalidCharacters:](foundation/nsurlcomponents/componentswithstring:encodinginvalidcharacters:.md)
- [init()](foundation/nsurlcomponents/init().md)
- [init(string:)](foundation/nsurlcomponents/init(string:).md)
- [init(string:encodingInvalidCharacters:)](foundation/nsurlcomponents/init(string:encodinginvalidcharacters:).md)
- [init(url:resolvingAgainstBaseURL:)](foundation/nsurlcomponents/init(url:resolvingagainstbaseurl:)-3bbte.md)
