UITableView Drag and Drop to Move Row Does Not Work

I am trying to use a drag delegate and drop delegate to rearrange rows in a UITableView. This is instead of using the edit-mode and move-handles that invoke the the moveRowAt of UITableViewDataSource.

The use of the drag delegate and drop delegate to accomplish this works great when running on iOS, but not on mac running via Catalyst.

What I see:
Code Block
tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath)
is called.

Code Block
tableView(_ tableView: UITableView, canHandle session: UIDropSession) -> Bool
is not called.

I'm not sure what else I can do to make the UITableView happy if this functionality already works on iOS.

The tableview is configured like:
Code Block
            tableView.dragDelegate = self
            tableView.dropDelegate = self
            tableView.dragInteractionEnabled = true


This is my final blocker before releasing a catalyst app for 10.15, and I would like to get it resolved before 10.16.

FB7737498 is filed to capture this behavior and has a sample project attached.

If there is an acceptable project host for the new forum, I can attach it here as well.
Answered by J0hn in 618906022
So I made it past this. The fix is "Weird" to say the least. It appears that an NSItemProvider constructed without an object will cause drop handlers to be invoked, despite a localObject being present on the UIDragItem.

I also seemed to have an issue with custom-type-dentifiers like "com.john.forum.post" not triggering drop handlers either.
If I put a standard NSString in the NSItemProvider it worked fine.

Given I was only using the localObject, I put an acceptabl user facing string in the NSItemProvider, and drag and drop worked fine for me on catalyst.
Link to sample project uploaded to Github:
https://github.com/johnpdavis/catalyst_reorder_example

https://github.com/johnpdavis/catalyst_reorder_example/blob/master/catalyst_reorder_example/ViewController.swift
Contains the configuration of the UITableView.

Running this on iOS you will observe the rows can be grabbed and drop to rearrange them.
Running this on macCatalyst you will observe the rows can be grabbed, but not dropped.
Accepted Answer
So I made it past this. The fix is "Weird" to say the least. It appears that an NSItemProvider constructed without an object will cause drop handlers to be invoked, despite a localObject being present on the UIDragItem.

I also seemed to have an issue with custom-type-dentifiers like "com.john.forum.post" not triggering drop handlers either.
If I put a standard NSString in the NSItemProvider it worked fine.

Given I was only using the localObject, I put an acceptabl user facing string in the NSItemProvider, and drag and drop worked fine for me on catalyst.
Thank you for sharing this! I had the exact same problem and ensuring that NSItemProvider was initialised with an object worked for me as well.

Here's my code:

Code Block swift
func tableView(_ tableView: UITableView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
return [UIDragItem(itemProvider: NSItemProvider(object: "Move" as NSItemProviderWriting))]
}

UITableView Drag and Drop to Move Row Does Not Work
 
 
Q