Last active
October 28, 2016 19:05
-
-
Save algal/186b5f979137854227782358e614814f to your computer and use it in GitHub Desktop.
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
// kg: Xcode 8, Swift 3 | |
extension FileHandle : TextOutputStream { | |
public func write(_ string: String) { | |
guard let data = string.data(using: .utf8) else { return } | |
self.write(data) | |
} | |
} | |
// now something like: | |
let url:URL = // url to file here | |
let path = url.path | |
guard let handle = FileHandle(forWritingAtPath:path) else { return } | |
defer { handle.closeFile() } | |
print(1,2,3,to:&handle) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment