Reading a line from the clipboard

How can I read a line from the clipboard and write it to the button title? I can copy the string to the clipboard with:

UIPasteboard.generalPasteboard().string = "Hello world" 

But how can I read this string from the clipboard and assign it String?

+7
ios swift
source share
1 answer

Just return it to the variable as follows:

 let pasteboardString: String? = UIPasteboard.general.string if let theString = pasteboardString { print("String is \(theString)") } 
+16
source share

All Articles