UIDropInteractionDelegate performDrop not called?
I just tested your code and all methods are getting called. It must be a glitch.
Troubleshooting steps:
Delete app -> Restart the simulator -> Clean build folder -> Rebuild -> Run. You can also try running in different simulator first to save time.
Receive JSON file in DropInteraction in iOS app running in Mac Catalyst
You don't need URL, because drop item already has item provider for JSON data, so it is just needed to extract that data from NSItemProvider
and decode.
Here is fixed parts (tested with Xcode 12.1)
func dropInteraction(_ interaction: UIDropInteraction, performDrop session: UIDropSession) {
session.items.forEach { item in
guard item.itemProvider.hasItemConformingToTypeIdentifier(SentimentViewController.JSONTypeIdentifier) else { return }
item.itemProvider.loadDataRepresentation(forTypeIdentifier: SentimentViewController.JSONTypeIdentifier) { data, error in
if let data = data {
self.importJSONData(from: data)
}
}
}
}
private func importJSONData(from data: Data) {
print("Decode JSON from \(data.description).")
}
Related Topics
Transit Mkdirectionsrequest Produces Null Error Error Domain=Mkerrordomain Code=5 "(Null)"
How to Hide API Keys in Github for iOS (Swift) Projects
Why am I Getting Com.Facebook.Sdk.Login Error 308
Swift Core Data Sync with Web Server
Reload View When @Published Is Changed
Cannot Invoke Initializer for Type Unsafemutablepointer<Uint8>
How to Center a Label Horizontally for All iOS Devices in Swift
Show Two Different Custom Cells in Same Uitableview - Swift Firebase
How to Add a Ibaction to a Button Programmatically in Swift 4
How to Check If Device Orientation Is Landscape Left or Right in Swift
Uiview Rounded Corner - Swift 2.0
How to Convert Data Dictionary into an Array Swift
iOS Swift Nsmutabledata Has No Member Appendstring
Using Static Libraries with Cocoapods 1.5 No Such Module at Import
Automatically Change Cell Height Based on Content - Swift
Swift iOS - Tag Collection View