Created
July 14, 2014 15:20
-
-
Save casademora/d06e69288fb24c9ace6e to your computer and use it in GitHub Desktop.
Extension to writeTo NSOutputStream
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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