How to copy a string to the clipboard

How to copy text to clipboard in xcode? I am currently using the following code:

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; [pasteboard setString:shareString]; 

When I try to paste this into another simulator application, I end up inserting all the view controller code. ??? Thanks in advance!

+6
source share
2 answers

You linked to this link: https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingCopy,Cut,andPasteOperations/UsingCopy,Cut,andPasteOperations.html

The amount of code you used seems convenient for copying text. Maybe more code will be helpful in understanding your problem. Meanwhile, you can go through this link, it is really useful.

+4
source

In Swift 3.0 you can copy text to a PasteBoard and paste anywhere. In short, if you want to copy text programmatically, then the code below will help you.

 let pasteBoard = UIPasteboard.general pasteBoard.string = "copy the text" 
0
source

Source: https://habr.com/ru/post/957761/


All Articles