How to copy string to clipboard
Solution 1
Did you refered this link : https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/UsingCopy,Cut,andPasteOperations/UsingCopy,Cut,andPasteOperations.html
The amount of code you have shared seems ok to copy text. May be more code will be helpful to understand your problem. Meanwhile you can go through this link , it is really helpful.
Solution 2
In Swift 3.0
you can copy text on PasteBoard
and paste anywhere. In short, if you want to copy text programmatically then below code will help you.
let pasteBoard = UIPasteboard.general
pasteBoard.string = "copy the text"
PanicDev
Updated on July 31, 2022Comments
-
PanicDev over 1 year
How do you copy text to the clipboard in xcode? Currently, I am using the following code:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; [pasteboard setString:shareString];
When I try to paste this into another one of the simulator apps, I end up pasting the entire view controller code. ??? Thanks in advance!