---
title: "componentsWithString:"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/nsurlcomponents/componentswithstring:"
---

# componentsWithString:

Returns a URL components object by parsing a URL in string form.

## Declaration

```occ
+ (instancetype) componentsWithString:(NSString *) URLString;
```

## Parameters

- `URLString`: The URL string to parse.

## Return Value

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

## See Also

### Creating URL components

- [componentsWithString:encodingInvalidCharacters:](foundation/nsurlcomponents/componentswithstring:encodinginvalidcharacters:.md)
- [componentsWithURL:resolvingAgainstBaseURL:](foundation/nsurlcomponents/componentswithurl:resolvingagainstbaseurl:.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)
