my code is trying to peremently delete a item from a core data set. This code works with a basic array like [“sarah”,“Jessica”]. However when trying to delete var itemName I am getting this error Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) at delegateA?.deleteData(indx: (index?.row)!). I dont know how to permanently delete the core data.All my code below is the parts of the code that function in the delete process.
class ViewController: UIViewController {
var itemName : [Item] = []
var collectionVC = UICollectionView()
}
protocol datacollectionProfotocol {
func deleteData(indx:Int)
}
class CustomCell: UICollectionViewCell {
var delegateA: datacollectionProfotocol?
@objc func ddelete() {
delegateA?.deleteData(indx: (index?.row)!)
}
}
extension ViewController: UICollectionViewDelegateFlowLayout, UICollectionViewDataSource {
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) as! CustomCell
cell.delegateA = self
}}