How to convert nameStruct to NSManagedObject?
<p><img src="https://i.stack.imgur.com/6NpaZ.png" alt="enter image description here">
<img src="https://i.stack.imgur.com/Sd3pW.png" alt="enter image description here"></p>

<pre><code>import UIKit
import CoreData

struct nameStruct {
   var name1:String?
   var name2:String?
}
</code></pre>

<p>//CoreData
    func saveName(name:nameStruct) {
        //1
        let  appDel:AppDelegate = UIApplication.shared.delegate as! AppDelegate
        let context:NSManagedObjectContext = appDel.persistentContainer.viewContext
        //2
        let entity =  NSEntityDescription.entity(forEntityName: "Zain",in:context)
        let person1 = NSManagedObject(entity: entity!,insertInto: context)
        //3
         person1.setValue(name.name1, forKey: "man1")
         person1.setValue(name.name2, forKey: "man2")
        //4
        do {
            try context.save()</p>

<pre><code>    } catch let error as NSError  {
        print("Could not save \(error), \(error.userInfo)")
    }
}



var array1 = [nameStruct]()

  //deleat row and tableview and arry
    func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {

          //  array1.remove(at: indexPath.row)
         //   ttableview.deleteRows(at: [indexPath], with: .fade)
            // delet Core Data

    let  appDel:AppDelegate = UIApplication.shared.delegate as! AppDelegate
    let  context:NSManagedObjectContext = appDel.persistentContainer.viewContext
         context.delete(array1[indexPath.row] as NSManagedObject)

            //4
      do {
         try context.save()     
        } catch let error as NSError  {
                print("Could not save \(error), \(error.userInfo)")
          }
          }
  }
</code></pre>