Appleとしてはペーストボードと呼びたいらしい.
NSPasteboard
を使う.なにか書き込む前にclearContents ()
を呼ぶのがポイント.なぜならドキュメントにそう書いてあるから.
Clears the existing contents of the pasteboard, preparing it for new contents. This is the first step in providing data on the pasteboard.
let pboard = NSPasteboard.general pboard.clearContents() pboard.setString("hoge", forType: .string)
眠いので終わり
--- 追記ここから 2021/08/12 21:14
iOSアプリというかUIKitのときはUIPasteboard
を使う.
つっこみがあったので追記
--- 追記終わり