-1

I come to you because I need your help for Swift 4.

So, this is why I need you: I searched to add text into UITextView when I tap on an UIButton. That’s OK, I have found the solution.

@IBAction func button1(_ sender: Any) {

    myTextView.text = "Button 1"
}

But, now, I search how to add this same text in my TextView with an list, in this case add the text many times I need and it adds in the form of a list each time in a new line.

I have four buttons and I want add text in TextView when I tap in an button but with an list. Example: Button 1 Button 2 Button 3 Button 4 Button 1 Button 2 Button 3 Button 4 Etc.

If you have the solution of course... Thank you!

1 Answers1

1

You need

let btStr = ""

myTextView.text =  "\(myTextView.text!)\n\(btStr)"
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • Sh_Khan Thank you! I test this! – Benjamin Tourin Mar 05 '19 at 11:49
  • 'code'@IBAction func button1(_ sender: Any) { let button1 = "Button 1" myTextView.text = "\(myTextView.text!)\n\(button1)" } @IBAction func button2(_ sender: Any) { let button2 = "Button 2" myTextView.text = "\(myTextView.text!)\n\(button2)" }'code" – Benjamin Tourin Mar 06 '19 at 10:00