0

I have the following code snippet for clearing user's clipboard:

func clearClipboard() {

    let pb = UIPasteboard.generalPasteboard()
    let pbtypes = pb.pasteboardTypes()

    for pbtype in pbtypes {
        pb.setValue("", forPasteboardType: pbtype)
    }

    print("Clipboard was cleared")
}

I tested the code on iPhone running iOS 8.4 and it works. However, on iOS 9.3 it doesn't work. On iOS 9.3, the pbtypes array is empty.

Did Apple change anything in the API permissions? Any advice will be appreciated.

Stasel
  • 1,298
  • 1
  • 13
  • 26

1 Answers1

0

So after more investigation it looks like this the way to clear the clipboard:

pb.setValue("", forPasteboardType: UIPasteboardNameGeneral)

Credit to this thread: How to clear/empty pasteboard on viewWillDisappear

Community
  • 1
  • 1
Stasel
  • 1,298
  • 1
  • 13
  • 26