Reading from the clipboard with Swift 3 on macOS

前端 未结 5 1789
轮回少年
轮回少年 2021-02-07 14:44

I\'m a beginner with Swift, and I\'m trying to figure out how can I read what has been copied to the clipboard On macOS (Swift 3)? I\'ve searched a lot but can\'t seem to find a

5条回答
  •  一整个雨季
    2021-02-07 15:01

    Easier ✅ Swift 4:

    @IBAction func pasteAction(_ sender: Any) {
        guard let stringToPaste: String = UIPasteboard.general.items.last?.first?.value as? String else { return }
        MYTEXTVIEW.text = stringToPaste
    }
    

提交回复
热议问题