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

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 {

catch {

notaLabelaverage.text = ""

nameTextField.text = ""
positionTextField.text = ""
age.text = ""
heightT.text = ""


     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 =

return cell


@objc func l1UPBTN(sender: UIButton){

//remove cat



@timswift Do you still have issues with this?

This topic was automatically closed after 166 days. New replies are no longer allowed.