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.
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.