An example for a PDF (com.adobe.pdf UTI) that implements NSItemProviderReading might NSItemProviderReading something like this:
class PDFDocument: NSObject, NSItemProviderReading { let data: Data? required init(pdfData: Data, typeIdentifier: String) { data = pdfData } static var readableTypeIdentifiersForItemProvider: [String] { return [kUTTypePDF as String] } static func object(withItemProviderData data: Data, typeIdentifier: String) throws -> Self { return self.init(pdfData: data, typeIdentifier: typeIdentifier) } }
Then in your deletet you need to process this PDFDocument:
extension YourClass: UIDropInteractionDelegate { func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool { return session.canLoadObjects(ofClass: PDFDocument.self)) } . . . func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) { session.loadObjects(ofClass: PDFDocument.self) { [unowned self] pdfItems in if let pdfs = pdfItems as? [PDFDocument], let pdf = pdfs.first {
kikettas
source share