Since copying and pasting are usually done in pairs, this is an additional answer to @ jtbandes's nice, concise answer. I originally came here to see how to insert.
iOS makes this easy, because a common dashboard can be used as a variable. Just get and install UIPasteboard.general.string .
Here is an example showing how both are used with a UITextField :
copy
UIPasteboard.general.string = myTextField.text
Embed
if let myString = UIPasteboard.general.string { myTextField.insertText(myString) }
Note that the line in the pasteboard is optional, so you must expand it first.
Suragch Jun 08 '16 at 1:50 2016-06-08 01:50
source share