Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy text to clipboard with iOS

People also ask

How do I enable clipboard in iOS?

Enable Handoff. On Macs, go to Apple menu > System Preferences > General > check the box next to Allow Handoff between this Mac and your iCloud devices. On iOS devices, go to Settings > General > Handoff > move the slider to on/green.

Does iPhone have a text clipboard?

All replies. There is no such in an iPhone. You will have Clipboard only when it can store multiple Cmd C or X, In an iPhone, you can store only one i.e. the last cmd X or C. Just tap on any text field and select “paste”.

How do I copy text in iOS?

After selecting the text you want to revise, you can type, or tap the selection to see editing options: Cut: Tap Cut or pinch closed with three fingers two times. Copy: Tap Copy or pinch closed with three fingers. Paste: Tap Paste or pinch open with three fingers.


Although the accepted answer is a good walkthrough of how UIPasteboard works, I figured I'd post the relevant snippet right here for everyone's convenience:

Obj-C

UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = @"Paste me!";

Swift 2.2

let pasteBoard = UIPasteboard.generalPasteboard()
pasteBoard.string = "Paste me!"

Swift 3+:

let pasteBoard = UIPasteboard.general
pasteBoard.string = "Paste me!"

Swift 2.2 :

let pasteBoard = UIPasteboard.generalPasteboard()
pasteBoard.string = "Paste Me !"

Swift 3:

let pasteBoard = UIPasteboard.general
pasteBoard.string = "Paste me!"