I am porting an App from Objective-C to Swift and I need to use the following method:
CFStreamCreatePairWithSocketToHost(alloc: CFAllocator!, host: CFString!
I worked out how to do it. A few important notes:
CMutablePointers will be automatically created if you use the & operator.T in an Unmanaged with .getUnretainedValue() and getRetainedValue() (Seems .getUnretainedValue() is analogous to __bridge_transfer)nil.nil it will translate into a false condition.So far I have (untested):
var readStream: Unmanaged?
var writeStream: Unmanaged?
CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, host, port, \
&readStream, &writeStream)
if (readStream && writeStream) {
inputStream = readStream!.takeUnretainedValue();
outputStream = writeStream!.takeUnretainedValue();
}