如何从swift 4中的剪贴板中获取文本

时间:2017-12-24 08:36:04

标签: ios swift

我不想写这个链接“https://stackoverflow.com/questions/ask”,如此行所示。我希望网址从剪贴板接收最后复制的网址,我应该添加什么?

let url = URL(string: "https://stackoverflow.com/questions/ask")

1 个答案:

答案 0 :(得分:4)

复制

let url = URL(string: "https://stackoverflow.com/questions/ask")
UIPasteboard.general.string = url

<强>粘贴

if let url = UIPasteboard.general.string {
        url = url
}