I have some text that user will be able to paste later on into UITextField. How can I copy that text programmatically?
Asked
Active
Viewed 116 times
0
-
1use UIPasteboard – Ashish Aug 21 '19 at 11:37
-
1copy `UIPasteboard.general.string = "Hello world"` and for paste `let content = UIPasteboard.general.string` – Nirav Kotecha Aug 21 '19 at 11:39
1 Answers
1
By from jtbandes's Answer
- To Copy
@IBAction fucn btnCopyClick(_ sender: UIButton)
{
UIPasteboard.general.string = YourTextField.text!
}
- Paste
let contentText = UIPasteboard.general.string

steveSarsawa
- 1,559
- 2
- 14
- 31
-
yes, thanks. I figured that from the commends by the two guys who commented under the question. – Anton Tropashko Aug 21 '19 at 12:00
-
Actually i done this same yesterday, so this is my one of favourites ;) – steveSarsawa Aug 21 '19 at 12:02