Created
May 31, 2016 19:52
-
-
Save russbishop/4c598a0f9988d70604dde1bc44d450d3 to your computer and use it in GitHub Desktop.
Allow use of NSFileHandle with print()
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
var standardError = NSFileHandle.fileHandleWithStandardError() | |
print("hi standard error", toStream: &standardError) |
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 NSFileHandle: OutputStreamType { | |
public func write(string: String) { | |
if let data = string.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: true) { | |
self.writeData(data) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment