<!--
{
  "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/getBuffer(_:length:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSInputStream(im)getBuffer:length:"
  },
  "title" : "getBuffer(_:length:)"
}
-->

# getBuffer(_:length:)

Returns by reference a pointer to a read buffer and, by reference, the number of bytes available, and returns a Boolean value that indicates whether the buffer is available.

```
func getBuffer(_ buffer: UnsafeMutablePointer<UnsafeMutablePointer<UInt8>?>, length len: UnsafeMutablePointer<Int>) -> Bool
```

## Parameters

`buffer`

Upon return, contains a pointer to a read buffer. The buffer is only valid until the next stream operation is performed.

`len`

Upon return, contains the number of bytes available.

## Return Value

<doc://com.apple.documentation/documentation/Swift/true> if the buffer is available, otherwise <doc://com.apple.documentation/documentation/Swift/false>.

## Discussion

Subclasses of `NSInputStream` may return <doc://com.apple.documentation/documentation/Swift/false> if this operation is not appropriate for the stream type.

---

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)