Last Run on XCODE 11.4 / Swift 5.2
If you are writing a command line tool and need user input, the readLine()
function
can be used for it. It returns an optional
let input = readLine()
And, if you dont want the ending new line character, you can set the strippingNewline
parameter
to true.
let input = readLine(strippingNewline: true)