Thanks for this wonderful book. Great to see something on macOS and SwiftUI as opposed to the extensive coverage of the mobile side of things.
I was implementing drag and drop in the CustomImageView in Chapter 13 and had a poke around in the documentation which said that onDrop(of:isTargeted:perform:)
is deprecated. I tried the following, which appears to work:
.onDrop(
of: [UTType.fileURL],
isTargeted: $dragOver
) { providers in
if let provider = providers.first {
provider.loadDataRepresentation(
forTypeIdentifier: UTType.fileURL.description) { data, _ in
loadURL(from: data)
}
}
return true
}