Reputation: 3045
How can I read a string from the clipboard and write it on a button's title? I can copy a string to the clipboard with:
UIPasteboard.generalPasteboard().string = "Hello world"
But how do I read that string from the clipboard and assign it to a String?
Upvotes: 16
Views: 6997
Reputation: 9149
Just read it back into a variable like this:
let pasteboardString: String? = UIPasteboard.general.string
if let theString = pasteboardString {
print("String is \(theString)")
}
Upvotes: 34