iap-Software iap-Software - 5 months ago 12
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"


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