我在 UITextView 中输入文本数据。我正在向 UITextView 添加多行。我从 TextView 得到的输出如下: Optional("Line1 line2 Line3"). 但我想打印出来如下:“Line1\nLine\2Line\3”。所以当我添加行文本时,我想看到输出 \n
我不希望它是可选的,但是 var text: String! 当我这样做时, Optional 没有出现,但是这次 \n 消失了。我想在行上查看 \n 输出
@IBOutlet weak var textInputArea: UITextView!
var text : String?
text = textInputArea.text
var new = text?.replacingOccurrences(of: "\\n", with: "\n", options: .regularExpression)
let jsString = "createText('\(newString)')"