Skip to content

Instantly share code, notes, and snippets.

@casademora
Created July 14, 2014 15:20
Show Gist options
  • Save casademora/d06e69288fb24c9ace6e to your computer and use it in GitHub Desktop.
Save casademora/d06e69288fb24c9ace6e to your computer and use it in GitHub Desktop.
Extension to writeTo NSOutputStream
extension String
{
func writeTo(outputStream:NSOutputStream)
{
if let data = self.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)
{
let bytes = ConstUnsafePointer<UInt8>(data.bytes)
outputStream.write(bytes, maxLength: data.length)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment