Copy text to clipboard with iOS

梦想与她 提交于 2019-11-28 02:50:20
samvermette

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 somewhere";

Swift 2.2

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

Swift 3+:

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

Swift 2.2 :

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

Swift 3:

let pasteBoard = UIPasteboard.general
pasteBoard.string = "Paste me!"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!