This question has already been answered:
@IBAction func testField(_ sender: UITextField) { let testText = sender.text } You must pass sender.text to other functions, but the testField function testField not return values. How to be?
This question has already been answered:
@IBAction func testField(_ sender: UITextField) { let testText = sender.text } You must pass sender.text to other functions, but the testField function testField not return values. How to be?
A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .
Create a variable not in view of the function. Next in the body of the function assign a value to it. And then you can use the variable in any other function.
var testText: String? @IBAction func testField(_ sender: UITextField) { testText = sender.text } func printTestText() { print(testText!) } Source: https://ru.stackoverflow.com/questions/585328/
All Articles