Read string from clipboard

前端 未结 1 664
温柔的废话
温柔的废话 2021-02-19 01:26

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         


        
相关标签:
1条回答
  • 2021-02-19 01:42

    Just read it back into a variable like this:

    let pasteboardString: String? = UIPasteboard.general.string
    if let theString = pasteboardString {
        print("String is \(theString)")
    }
    
    0 讨论(0)
提交回复
热议问题