How do I use UIPasteBoard without full access and make a local pasteboard instead of using the universal pasteboard across all devices?

This is my code to copy an image on to the general UIPateBoard and paste it:


//image paste code

let pb = UIPasteboard.general

let imgData : Data? = image.pngData()

pb.setData(imgData!, forPasteboardType: kUTTypePNG as String)


This will not work unless full acess is granted. Even if i declare it this way:


let pb = UIPasteboard.init(name: "New", create: true)


OR:


//try to declare it local after its created

pb.setItems([["Key":"Data"]], options: [UIPasteboard.OptionsKey.localOnly : true])


I am still not able to paste. Do I need to use the paste function from the UIInputViewController from the custom keyboard?

Replies

>//try to declare it local after its created


I believe that should work - did you follow it with a 'clean build folder' via the Product menu to convince Xcode of the change(s)?