Спасибо @Sachin Raut

чал, как удалить строку из табличного представления, данные которого находятся в Базовых данных. Я не могу найти в Интернете ничего, что помогло бы мне с моим кодом. Я действительно новичок в Core Data, поэтому я не очень разбираюсь в этом.

заранее спасибо

Это мой код

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)

    guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return}

    let managedContext = appDelegate.persistentContainer.viewContext

    let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "OfficialPT")
    fetchRequest.sortDescriptors = [NSSortDescriptor(key:"createdAt",ascending:false)]


    do {
        AirForceDatabase = try managedContext.fetch(fetchRequest)
    } catch let error as NSError {
        print("Could not fetch. \(error), \(error.userInfo)")
    }
}

func SideMenus ()
{
    if revealViewController() != nil {
        MenuButton.target = revealViewController()
        MenuButton.action = #selector(SWRevealViewController.revealToggle(_:))
        revealViewController().rearViewRevealWidth = 275
        revealViewController().rightViewRevealWidth = 160

        // profileButton.target = revealViewController()
        // profileButton.action = #selector(SWRevealViewController.rightRevealToggle(_:))

        view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())


    }
}

}

расширение HistoryPTViewController: UITableViewDataSource {

func tableView(_ tableView: UITableView,
               numberOfRowsInSection section: Int) -> Int {
    return AirForceDatabase.count
}


func tableView(_ tableView: UITableView,
               cellForRowAt indexPath: IndexPath) -> UITableViewCell {




    if let cell = tableView.dequeueReusableCell(withIdentifier: "Cell",for: indexPath) as? HistoryPTTableViewCell {


    let person = AirForceDatabase[indexPath.row]

       cell.OfficialAbsLbl!.text = person.value(forKeyPath: "officialAbs")! as? String
        cell.OfficialPushLbl!.text = person.value(forKeyPath: "officialPush")! as? String
        cell.OfficialSitLbl!.text = person.value(forKeyPath: "officialSit")! as? String
        cell.OfficialRunLbl!.text = person.value(forKeyPath: "officialRun")! as? String
        cell.officialTotal!.text = person.value(forKeyPath: "totalScore")! as? String
        cell.officialdateCreated.text = person.value(forKeyPath: "createdAt")! as? String







    return cell
}
return UITableViewCell()

}

} расширение HistoryPTViewController: UITableViewDelegate {

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: true)

     let person = AirForceDatabase[indexPath.row]
    //Convert String to Double
    if let score = person.value(forKeyPath: "totalScore")! as? String, let doubleScore = Double(score) {

        officialTotalScore = doubleScore
        //officialTotalScore = Double(score)

        print("Score \(officialTotalScore)")

    }
    var createdat :String!

    CompostiveLbl.text = "Composite Score:\n\(officialTotalScore)%"
    createdat = person.value(forKeyPath: "createdAt")! as? String
    print(createdat + "CREATED")
    if officialTotalScore >= 90 {
        print("Excellent")

        officialFinalScoreLbl.text = "Fitness Level:\n Excellent"
    }else if officialTotalScore >= 75 && officialTotalScore <= 89.9 {


        print("Composite Score: Satisfactory")
        officialFinalScoreLbl.text = "Fitness Level:\n Satisfactory"

    }else if  officialTotalScore <= 75 {

        print("Composite Score: Unsatisfactory")
        officialFinalScoreLbl.text = "Fitness Level:\n  Unsatisfactory"
    }





    let dateFormatter = DateFormatter()
    dateFormatter.dateStyle = DateFormatter.Style.long
    dateFormatter.dateFormat = "yyyy-MM-dd"
    let convertedDate = dateFormatter.date(from: createdat)
    dateFormatter.dateFormat = "MMM dd yyyy"
    let date = dateFormatter.string(from: convertedDate!)

    NextPTLbl.text = "Test Date:\n" + date
}


func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {

       let person = AirForceDatabase[indexPath.row]
    if editingStyle == .delete {






   }


}

Ответы на вопрос(1)

Ваш ответ на вопрос