Xcode 6, Swift - reading standard input (console) into a string

I'm new to Objective-C and Xcode, and I'm trying to learn something new. Is there a way to read a string from stdin using swift? Something like cin in C ++?

+8
swift xcode6
source share
1 answer

As with Objective-C, you can use NSFileHandle :

 let standardInput = NSFileHandle.fileHandleWithStandardInput() let input = standardInput.availableData 
+11
source share

All Articles