I have a SwiftUI View conforming to DropDelegate
and working correctly in order to receive images from other apps in macOS
and iPadOS
, but the behavior in both operative systems are quite different:
struct ContentView: View {
var body: some View {
MyView { ... }
.onDrop(of: [.fileURL, .image], delegate: self)
}
}
And the DropDelegate
implementation is:
extension ContentView: DropDelegate {
func performDrop(info: DropInfo) -> Bool {
// Debug implementation
if info.hasItemsConforming(to: [.image]) {
print("CONTAINS AN IMAGE")
} else if info.hasItemsConforming(to: [.fileURL]) {
print("CONTAINS AN URL")
}
}
}
If I'm on macOS
the output is CONTAINS AN URL
, and if I'm on iPadOS
the output is CONTAINS AN IMAGE
.
The problem is that I need to access to some metadata (like the creationDate
) of the source URL, and I cannot access to the creationDate
if the output is an UIImage
. How can I access to the source URL on iPadOS/iOS via DropDelegate? Or... How can I get the creationDate of an UIImage
provided by DropDelegate
?
Xcode 13 | macOS 12 | iPadOS 15 | Swift 5.5 | SwiftUI 3.0