<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.0.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/InputStream/init(data:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSInputStream(im)initWithData:"
  },
  "title" : "init(data:)"
}
-->

# init(data:)

Initializes and returns an `NSInputStream` object for reading from a given `NSData` object.

```
init(data: Data)
```

## Parameters

`data`

The data object from which to read. The contents of `data` are copied.

## Return Value

An initialized `NSInputStream` object for reading from `data`.

## Discussion

The stream must be opened before it can be used.

## See Also

[`+  inputStreamWithData:`](/documentation/Foundation/NSInputStream/inputStreamWithData:)

Creates and returns an initialized `NSInputStream` object for reading from a given `NSData` object.



---

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)