It seems to me that NSItemProvider doesn't work well in the latest Xcode 12 (macOS 10.15.6).
No matter what file types I'm trying to drop, I can never load them.
The error I'm getting:
Drop delegate:
I've tried this code with different type identifiers: audio, image, etc. All failed.
Anyone knows what's the issue?
No matter what file types I'm trying to drop, I can never load them.
The error I'm getting:
And here's my code:Error Domain=NSItemProviderErrorDomain Code=-1000 "Cannot load representation of type public.audio" UserInfo={NSLocalizedDescription=Cannot load representation of type public.audio}
Code Block swift // My SwiftUI View Color.red .onDrop(of: ["public.audio"], delegate: self)
Drop delegate:
Code Block swift func performDrop(info: DropInfo) -> Bool { let provider = info.itemProviders(for: ["public.audio"])[0] provider.loadFileRepresentation(forTypeIdentifier: "public.audio") { (url, error) in guard let url = url, error != nil else { print(error!.localizedDescription) return } ... }
I've tried this code with different type identifiers: audio, image, etc. All failed.
Anyone knows what's the issue?