Hi all, Another question. I used to use this snippet to read keyboard input from XCode's Playground. And it used to work very well. Today, I just updated my XCode to v.8 and Swift v.3. After a little bit modification here and there due to Swift 3 incompatibility, I got this code compiled without error. But it doesn't work. No keyboard input is taken. It just stucks. Here's the code: import Foundation func input() -> String { let keyboard = FileHandle.standardInput let inputData = keyboard.availableData let encoding = String.Encoding(rawValue: String.Encoding.utf8.rawValue) let strData = String(data: inputData, encoding: encoding) return strData! as String} func write(_ txt: String) { print(txt, terminator: "")} func read() -> String { let c = CharacterSet.whitespacesAndNewlines return input().trimmingCharacters(in: c)}
/* main program */ write("Enter your name: ")let s = read() So, does anyone know how to make it works (again)? Thank you. Regards, –Mr Bee
_______________________________________________ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users