<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "NetworkExtension",
  "identifier" : "/documentation/NetworkExtension/NEAppProxyTCPFlow/write(_:withCompletionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Network Extension"
    ],
    "preciseIdentifier" : "c:objc(cs)NEAppProxyTCPFlow(im)writeData:withCompletionHandler:"
  },
  "title" : "write(_:withCompletionHandler:)"
}
-->

# write(_:withCompletionHandler:)

Write data to the flow.

```
func write(_ data: Data, withCompletionHandler completionHandler: @escaping @Sendable ((any Error)?) -> Void)
```

## Parameters

`data`

An <doc://com.apple.documentation/documentation/Foundation/NSData> object containing the data to write.

`completionHandler`

A block that will be executed by the system on an internal system thread when the data is written into the receive buffer of the socket associated with the flow. The caller should use this callback as an indication that it is possible to write more data to the flow without using up excessive buffer memory. If an error occurs while writing the data then a non-nil <doc://com.apple.documentation/documentation/Foundation/NSError> object is passed to the block. See `NEAppProxyFlowError` in [`NEAppProxyFlow`](/documentation/NetworkExtension/NEAppProxyFlow) for a list of possible errors.

---

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)