Copy text to clipboard with iOS
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!"