-
-
Save mingsai/9db593f182a11235d8c3 to your computer and use it in GitHub Desktop.
Extension to writeTo NSOutputStream
This file contains hidden or 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