I have a collection view that displays data arranged in a custom data model (struct) called "claimData."
claimData declaration:
struct claimData {
var image = UIImage()
var imageTitle = String()
var hasCustomDescription = Bool()
var customDescription = String()
var isAnInitial = Bool()
var isDamage = Bool()
var isUnrelated = Bool()
var isAnOption = Bool()
var isACondition = Bool()
}
I share the state of this data via a sharedInstance because I am utilizing a floating panel.
class PageDataSource {
var theData: ReviewDataController?
static let sharedInstance = PageDataSource()
private init() {}
}
ReviewDataController simply holds an array of claimData called "tableViewReviewData".
I'm trying to implement the Drag/Drop feature in my floating panel's collectionView, but I can't seem to get the itemProvider working with my custom data model.
This is what I have at the moment:
func collectionView(_ collectionView: UICollectionView, itemsForBeginning session: UIDragSession, at indexPath: IndexPath) -> [UIDragItem] {
let item = PageDataSource.sharedInstance.theData?.tableViewReviewData[indexPath.item]
let itemProvider = NSItemProvider(object: item)
let dragItem = UIDragItem(itemProvider: itemProvider)
dragItem.localObject = item
return [dragItem]
}
This is the error I'm getting for the itemProvider: "Argument type 'claimData?' does not conform to expected type 'NSItemProviderWriting'"
Thanks for your help and let me know if you have any questions!!