I have a Problem implementing drag and drop in my App.
My code is the following:
Everything is working fine on macOS. But if I run the same code on iOS or iPadOS it does not work. Everything inside the .loadObject() {...} method is not executed. If I print something to console in this method, it will not be printed. This also works fine on macOS. The weird part is, that the exact same code is executed fine in the performDrop method.
Am I missing something important, or is this a bug? Because it all works fine when executed on macOS. I hope someone can help me.
My code is the following:
Code Block swift struct MyDropDelegate: DropDelegate { ... func performDrop(info: DropInfo) -> Bool { let items = info.itemProviders(for: ["public.url"]) for item in items { _ = item.loadObject(ofClass: URL.self) { data, error in if let url = data { ... } } } return true } func dropEntered(info: DropInfo) { let items = info.itemProviders(for: ["public.url"]) for item in items { _ = item.loadObject(ofClass: URL.self) { data, error in if let url = data { ... } } } } ... }
Everything is working fine on macOS. But if I run the same code on iOS or iPadOS it does not work. Everything inside the .loadObject() {...} method is not executed. If I print something to console in this method, it will not be printed. This also works fine on macOS. The weird part is, that the exact same code is executed fine in the performDrop method.
Am I missing something important, or is this a bug? Because it all works fine when executed on macOS. I hope someone can help me.