+ 2
How to take user input in swift?
6 Respuestas
+ 2
use readLine, from the Swift Standard Library.
https://developer.apple.com/reference/swift/1641199-readline
Example:
let response = readLine(strippingNewline: true)
Will give you an Optional value containing the entered text.
+ 1
Did you meant taking user input from a text field ?
+ 1
1. You need to map your textfield property from storyboard or xib to its corresponding class file.
2. In class file, 'yourTextFieldName.text' will provide you the value entered by the user.
0
yup
0
var name = readLine()
0
will give you input stored inside of a variable called name.