I have this code:
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return productsObjectArray.count
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell10", for: indexPath) as! MainViewCollectionViewCell
let objProduct = productsObjectArray[indexPath.item]
cell.titleLabel.text = objProduct.name
let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
let imageFileName = objProduct.code
let fullImagePath = documentsDir.appendingPathComponent("GET_PHOTO").path + "/" + imageFileName! + ".jpg"
cell.imageView.image = UIImage(contentsOfFile: fullImagePath)
let swipeRight = UISwipeGestureRecognizer(target: self, action: #selector(MainViewControler.rightSwiped))
swipeRight.direction = UISwipeGestureRecognizerDirection.right
cell.addGestureRecognizer(swipeRight)
let swipeLeft = UISwipeGestureRecognizer(target: self, action: #selector(MainViewControler.leftSwiped))
swipeLeft.direction = UISwipeGestureRecognizerDirection.left
cell.addGestureRecognizer(swipeLeft)
cell.favoriteBtn1.tag = indexPath.row
cell.favoriteBtn1.addTarget(self, action: #selector(didTapButton(_:)), for: .touchUpInside)
return cell
}
@objc func didTapButton(_ sender: UIButton) {
let objProduct = productsObjectArray[indexPath.item]
print(objProduct.id)
print(objProduct.code)
}
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
let productObject = productsObjectArray[indexPath.item]
showSubViewInContainerViewProductCard(view: "ProductDetailView", object: [productObject], productsFilter: 0, marketProductsFilter: 0, menuFilter: 0, preparationFilter: 0, glutenFilter: 0, backFromProductView: false)
}
This is my StoryBoard:
How can I display in "clicked product id: ......" after clicking button favoriteBtn1 which product code was clicked?
How can I do this?