---
title: CFWriteStream
framework: corefoundation
role: symbol
role_heading: Class
path: corefoundation/cfwritestream
---

# CFWriteStream

## Declaration

```swift
class CFWriteStream
```

## Overview

Overview CFWriteStream provides an interface for writing a byte stream either synchronously or asynchronously. You can create streams that write bytes to a block of memory, a file, or a generic socket. All streams need to be opened, using CFWriteStreamOpen(_:), before writing. Use CFReadStream for reading byte streams, and for the functions, such as CFStreamCreatePairWithSocketToHost(_:_:_:_:_:), that create socket streams). CFWriteStream is “toll-free bridged” with its Cocoa Foundation counterpart, OutputStream. This means that the Core Foundation type is interchangeable in function or method calls with the bridged Foundation object. Therefore, in a method where you see an NSOutputStream * parameter, you can pass in a CFWriteStreamRef, and in a function where you see a CFWriteStreamRef parameter, you can pass in an NSOutputStream instance. Note, however, that you may have either a delegate or callbacks but not both. See Toll-Free Bridged Types for more information on toll-free bridging.

## Topics

### Creating a Write Stream

- [CFWriteStreamCreateWithAllocatedBuffers(_:_:)](corefoundation/cfwritestreamcreatewithallocatedbuffers(_:_:).md)
- [CFWriteStreamCreateWithBuffer(_:_:_:)](corefoundation/cfwritestreamcreatewithbuffer(_:_:_:).md)
- [CFWriteStreamCreateWithFile(_:_:)](corefoundation/cfwritestreamcreatewithfile(_:_:).md)

### Opening and Closing a Stream

- [CFWriteStreamClose(_:)](corefoundation/cfwritestreamclose(_:).md)
- [CFWriteStreamOpen(_:)](corefoundation/cfwritestreamopen(_:).md)

### Writing to a Stream

- [CFWriteStreamWrite(_:_:_:)](corefoundation/cfwritestreamwrite(_:_:_:).md)

### Scheduling a Write Stream

- [CFWriteStreamScheduleWithRunLoop(_:_:_:)](corefoundation/cfwritestreamschedulewithrunloop(_:_:_:).md)
- [CFWriteStreamUnscheduleFromRunLoop(_:_:_:)](corefoundation/cfwritestreamunschedulefromrunloop(_:_:_:).md)

### Examining Stream Properties

- [CFWriteStreamCanAcceptBytes(_:)](corefoundation/cfwritestreamcanacceptbytes(_:).md)
- [CFWriteStreamCopyProperty(_:_:)](corefoundation/cfwritestreamcopyproperty(_:_:).md)
- [CFWriteStreamCopyError(_:)](corefoundation/cfwritestreamcopyerror(_:).md)
- [CFWriteStreamGetError(_:)](corefoundation/cfwritestreamgeterror(_:).md)
- [CFWriteStreamGetStatus(_:)](corefoundation/cfwritestreamgetstatus(_:).md)

### Setting Stream Properties

- [CFWriteStreamSetClient(_:_:_:_:)](corefoundation/cfwritestreamsetclient(_:_:_:_:).md)
- [CFWriteStreamSetProperty(_:_:_:)](corefoundation/cfwritestreamsetproperty(_:_:_:).md)

### Getting the CFWriteStream Type ID

- [CFWriteStreamGetTypeID()](corefoundation/cfwritestreamgettypeid().md)

### Callbacks

- [CFWriteStreamClientCallBack](corefoundation/cfwritestreamclientcallback.md)

## Relationships

### Conforms To

- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)

## See Also

### Opaque Types

- [CFAllocator](corefoundation/cfallocator.md)
- [CFArray](corefoundation/cfarray.md)
- [CFAttributedString](corefoundation/cfattributedstring.md)
- [CFBag](corefoundation/cfbag.md)
- [CFBinaryHeap](corefoundation/cfbinaryheap.md)
- [CFBitVector](corefoundation/cfbitvector.md)
- [CFBoolean](corefoundation/cfboolean.md)
- [CFBundle](corefoundation/cfbundle.md)
- [CFCalendar](corefoundation/cfcalendar.md)
- [CFCharacterSet](corefoundation/cfcharacterset.md)
- [CFData](corefoundation/cfdata.md)
- [CFDate](corefoundation/cfdate.md)
- [CFDateFormatter](corefoundation/cfdateformatter.md)
- [CFDictionary](corefoundation/cfdictionary.md)
- [CFError](corefoundation/cferror.md)
