I have a view that conforms to DropDelegate. When a file is dragged from the Finder and dropped on the view, the performDrop(info:) method successfully extracts a URL from the item provider and returns true, but the drag image slides away as if the drop had been rejected. Why?
func performDrop(info: DropInfo) -> Bool {
bgColor = .yellow
let providers = info.itemProviders(for: [.fileURL])
print("performDrop, providers: \(providers.count)")
if let aProvider = providers.first
{
if aProvider.hasItemConformingToTypeIdentifier(UTType.url.identifier)
{
aProvider.loadItem(forTypeIdentifier: UTType.url.identifier)
{ (item, error) in
if let error = error {
print("Error retrieving item provider data: \(error.localizedDescription)")
return
}
if let url = item as? URL
{
print("Received file URL (from Data.1): \(url)")
}
else if let data = item as? Data, let url = URL(dataRepresentation: data, relativeTo: nil)
{
print("Received file URL (from Data.2): \(url)")
}
}
}
}
return true
}