In order to make our filter items draggable, we have quite a few things to do. First, we need to update our PhotoFilterViewController+UIDropInteraction
file. Open it up, look for the -dropInteraction:canHandleSession:
method, and update the else
statement from false
to the following:
else { return session.canLoadObjects(ofClass: FilterItem.self) }
When you are done, your method will look like the following:
func dropInteraction(_ interaction: UIDropInteraction, canHandle session: UIDropSession) -> Bool { if session.localDragSession == nil { return session.canLoadObjects(ofClass: UIImage.self) } else { return session.canLoadObjects(ofClass: FilterItem.self) } }
You can ignore the error for now. Here, we are just making sure that our FilterItem
class can be dropped and loaded. Now, we need to do one more update in this class: find the -dropInteraction:performDrop:
method. After the if
statement we are going to add an else
:
else { for...