<p>I wasn't able to get the examples others have provided in this thread to work. Sure, they compiled, but they crashed as soon as the connection was open.</p>
<p>However, I noticed in the WWDC 2014 discussions (and iOS 8 release notes) that there is a new method for initializing an NSStream for creating a bound pair of in/out streams.</p>
<pre><code>var inputStream: NSInputStream?
var outputStream: NSOutputStream?
NSStream.getStreamsToHostWithName("localhost", port: 1234, inputStream: &inputStream, outputStream: &outputStream)
<p>This removes the need for the awkward CFStreamCreatePairWithSocketToHost call as well as removing the need for Unmanaged resources.</p>
<p>This tip was originally posted on <a href="http://stackoverflow.com/questions/24028995/Toll-free%20bridging%20and%20pointer%20access%20in%20Swift/24539363">Stack Overflow</a>.</p>