---
title: "init(dataRepresentation:relativeTo:isAbsolute:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/url/init(datarepresentation:relativeto:isabsolute:)"
---

# init(dataRepresentation:relativeTo:isAbsolute:)

Initializes a newly created URL using the contents of the given data, relative to a base URL.

## Declaration

```swift
init?(dataRepresentation: Data, relativeTo base: URL?, isAbsolute: Bool = false)
```

## Discussion

Discussion If the data representation isn’t a legal URL string as ASCII bytes, the URL object may not behave as expected. This initializer returns nil if it can’t form a valid URL from the provided string.

## See Also

### Working with the data representation of a URL

- [dataRepresentation](foundation/url/datarepresentation.md)
