如何从剪贴板中读取字符串并将其写在按钮的标题上?我可以将字符串复制到剪贴板:
UIPasteboard.generalPasteboard().string = "Hello world"
但是如何从剪贴板中读取该字符串并将其分配给String?
答案 0 :(得分:22)
只需将其读回如下变量:
let pasteboardString: String? = UIPasteboard.general.string
if let theString = pasteboardString {
print("String is \(theString)")
}