Skip to content

Instantly share code, notes, and snippets.

@mingsai
Forked from casademora/gist:d06e69288fb24c9ace6e
Created February 16, 2016 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mingsai/9db593f182a11235d8c3 to your computer and use it in GitHub Desktop.
Save mingsai/9db593f182a11235d8c3 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