Search code examples
iosobjective-cstringpaste

How to copy string to clipboard


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!


Solution

  • 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.