Hi, I am building a List with a list of files saved in my app. I also want this to accept drops of multiple types of files (images, audio, PDFs, Excel, Pages etc) ... basically anything that be dragged-and-dropped from the iOS system or apps like Mail, iCloud Drive etc. I'm trying to find a good way to handle this.
The best I've come across is adding the onInsert
option to accept UTTypes, like this:
List {
...
}
.onInsert(of: [UTType.data], perform: dropAction)
But now I'm not sure how I can load the object that was dropped here. From some examples I've seen, If I registered the UTType.image
instead, I could load it in the dropAction
handler like this:
item.loadObject(ofClass: UIImage.self) { image, _ in
DispatchQueue.main.async {
print("Image type dropped")
}
}
But how does that work for 'data' types. Or am I supposed to list out all the data types separately?