---
title: "init(contentsOf:options:)"
framework: foundation
role: symbol
role_heading: Initializer
path: "foundation/data/init(contentsof:options:)"
---

# init(contentsOf:options:)

Creates data by reading from the specified URL.

## Declaration

```swift
init(contentsOf url: URL, options: Data.ReadingOptions = []) throws
```

## Parameters

- `url`: The URL to read.
- `options`: Options for the read operation. Default value is [].

## Discussion

Discussion note: An error in the Cocoa domain, if url cannot be read.
