Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 6, Swift - read standard input (console) to string [closed]

Tags:

swift

xcode6

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++ ?

like image 829
user3708688 Avatar asked Jun 04 '14 20:06

user3708688


1 Answers

Just as with Objective-C, you can use NSFileHandle:

let standardInput = NSFileHandle.fileHandleWithStandardInput()
let input = standardInput.availableData
like image 167
Austin Avatar answered Nov 04 '22 14:11

Austin