iap-Software iap-Software - 1 year ago 97
Swift Question

Get New Line without Losing Text

I've got a text view and I want to add a button that when clicked creates a new line. I've tried things like \r and \r\n, but both delete what is currently in the text view. I want to be able to create a new line without having the current text in the view deleted. This is what I've got so far:

@IBAction func line(sender: AnyObject) {
textView.text = "\r"

Answer Source

textView.text = textView.text + "\n"

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download