Group Group Group Group Group Group Group Group Group

How to hide one element of a core data array on tableview cell swift 5

#1

I am trying to be able to hide a attribute of a core data array. There are 5 core data attributes and I only want to display 4 of them. When A user hits a button. Below is my code in the view controller. My code loads and works its just I do not know how to do this. When the user hits the button for the function I want to hide attribute cat from the all of the tableview cells. I added a example of what I am trying to in picture below.

              class ViewController: UIViewController, UITableViewDataSource,   UITableViewDelegate {
      var itemName : [NSManagedObject] = []
      func enterData() {

let appDeldeaget = UIApplication.shared.delegate as! AppDelegate



let context = appDeldeaget.persistentContainer.viewContext



let entity = NSEntityDescription.entity(forEntityName: "Data", in: context)



let theTitle = NSManagedObject(entity: entity!, insertInto: context)
//






theTitle.setValue(notaLabelaverage.text, forKey: "cat")
theTitle.setValue(nameTextField.text, forKey: "age")
theTitle.setValue(heightT.text, forKey: "hits")
theTitle.setValue(age.text, forKey: "weight")
theTitle.setValue(positionTextField.text, forKey: "positon")

do {
    try context.save()
    itemName.append(theTitle)

}
catch {
    print("d")
}
self.theScores.reloadData()

notaLabelaverage.text = ""
notaLabelaverage.resignFirstResponder()

nameTextField.text = ""
nameTextField.resignFirstResponder()
positionTextField.text = ""
positionTextField.resignFirstResponder()
age.text = ""
age.resignFirstResponder()
heightT.text = ""
heightT.resignFirstResponder()


      }




     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let title = itemName[indexPath.row]
let cell = theScores.dequeueReusableCell(withIdentifier: "MyCell", for : indexPath)
cell.textLabel!.numberOfLines = 2
cell.selectionStyle = .default



    let attr1 = title.value(forKey: "cat") as? String


    let attr3 = title.value(forKey: "age") as? String
    let attr4 = title.value(forKey: "weight") as? String

    let attr2 = title.value(forKey: "hits") as? String
    let attr5 = title.value(forKey: "positon") as? String

    let text = [attr1,"  Weight :",attr3,"\n","Height : ",attr2," Age : ",attr4," Position :",attr5].flatMap { $0 }.reduce("", +)
    cell.textLabel?.text = "\(text)"




cell.textLabel?.textAlignment = .center

cell.layoutMargins = UIEdgeInsets.zero






return cell

       }

@objc func l1UPBTN(sender: UIButton){


//remove cat

            }
       }

#2

@timswift Do you still have issues with this?