问题
I am new to Objective-C and XCode and I'm trying to learn something new. Is there any way to read string from stdin using swift ? Something like cin in C++ ?
回答1:
Just as with Objective-C, you can use NSFileHandle:
let standardInput = NSFileHandle.fileHandleWithStandardInput()
let input = standardInput.availableData
来源:https://stackoverflow.com/questions/24046952/xcode-6-swift-read-standard-input-console-to-string