Problem when dropping a pdf file

Hi! I'm dropping a pdf file in an app, and I'm getting 2 errors I cannot understand. When I drop the file I'm supposed to create a pdf view, which, by the way I can. I perform the drop th in a swiftui view.
     
Code Block
      GeometryReader { geometry in
                ZStack {
                    Rectangle()
                        .foregroundColor(.white)
                        .overlay(OptionalPDFView(pdfDocument: self.document.backgroundPDF))                    
                }.onDrop(of: ["public.data"], isTargeted:nil) { providers, location in
                    for provider in providers {
provider.loadDataRepresentation(forTypeIdentifier: "public.data") { (data, err) in
                            if let safeData = data {
                                self.document.setBackgroundData(data: safeData)
                            } else {
                                print("problem")
                            }
                        }
                    }
]                    return self.drop(providers: providers, al: location)
                }
            }


The problem is if I define and on drop of public.adobe.pdf, nothing is recognized when I drag a file into it, and when I specify public.data and I want to extract the provider data for that identifier, I get this console message : " Cannot find representation conforming to type public.data".
I'm trying to build a Mac app (Appkit).
Thanks a lot.
  • Did you find a solution? As far as I know it works if instead of public.data I use [.fileURL] but then any file can be dropped.

Add a Comment