Home>
I want to ask

The content saved on the add screen is not reflected in the cell.
It seems that it has been done so far and disappeared while fixing the code. I would appreciate it if you could tell me the missing part without going back to the original part with command + z.

Code
// Home
//Home Screen
import UIKit

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
    @IBOutlet weak var memoTableView: UITableView!
// var memoArray = [String] ()
    let ud = UserDefaults.standard
    func tableView (_ tableView: UITableView, numberOfRowsInSection section: Int)->Int {
        return MemonoNakami.count
    }

    func tableView (_ tableView: UITableView, cellForRowAt indexPath: IndexPath)->UITableViewCell {
        let cell = tableView.dequeueReusableCell (withIdentifier: "memoCell", for: indexPath)
        cell.textLabel? .text = MemonoNakami [indexPath.row]
        return cell
    }
    func tableView (_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        self.performSegue (withIdentifier: "toDetail", sender: nil)
        // Press to release the pressed state
        tableView.deselectRow (at: indexPath, animated: true)
    }

    override func viewDidLoad () {
        super.viewDidLoad ()
        // Get the content entered on the add screen
        if UserDefaults.standard.object (forKey: "TodoList")! = nil {
            MemonoNakami = UserDefaults.standard.object (forKey: "TodoList") as! [String]
        }
// memoTableView.delegate = self
// memoTableView.dataSource = self
        memoTableView.reloadData ()
    }
    override func viewWillAppear (_ animated: Bool) {
        loadMemo ()
    }
    override func prepare (for segue: UIStoryboardSegue, sender: Any?) {
        // Destination crash prevention
        if segue.identifier == "toDetail" {
            // get detailViewController
            // as! Downcast with DetailViewController
            let detailViewController = segue.destination as! DetailViewController
            // Can get the selected cell before transition
            let selectedIndexPath = memoTableView.indexPathForSelectedRow!
            detailViewController.selectedMemo = MemonoNakami [selectedIndexPath.row]
            detailViewController.selectedRow = selectedIndexPath.row
        }
    }
    func loadMemo () {
        if ud.array (forKey: "memoArray")! = nil {
            // Get only when it is not nil because it is unwrapped with as!
            MemonoNakami = ud.array (forKey: "memoArray") as! [String]
            // reloads mememoTableView.reloadData ()
        }
    }
    func tableView (_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
        if editingStyle == .delete {
            // remove the indexPath row in the resultArray
            MemonoNakami.remove (at: indexPath.row)
            // Save the deleted array in the app again
            ud.set (MemonoNakami, forKey: "memoArray")
            // Update tableView
            tableView.reloadData ()
        }
    }
}
// Add screen
import UIKit
import SwiftyTesseract
var MemonoNakami = [String] ()
class AddViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    @IBOutlet weak var memoTextView: UITextView!
    @IBOutlet weak var imageView: UIImageView!
    @IBOutlet weak var imageButton: UIButton!
    let swiftyTesseract = SwiftyTesseract (language: RecognitionLanguage.japanese)
    let saveData: UserDefaults = UserDefaults.standard
    // Process when camera button is tapped
    @IBAction func launchCamera (_ sender: UIButton) {
        let camera = UIImagePickerController.SourceType.camera
        if UIImagePickerController.isSourceTypeAvailable (camera) {
            let picker = UIImagePickerController ()
            picker.sourceType = camera
            picker.delegate = self
            self.present (picker, animated: true)
        }
        imageView.isHidden = false
        imageButton.isHidden = true
    }
        // Select photo from album
        @IBAction func openAlbum () {
            // Check if the camera roll can be used
            if UIImagePickerController.isSourceTypeAvailable (.photoLibrary) {
                // Sequential flow from selecting the camera roll image to displaying the image
                let picker = UIImagePickerController ()
                picker.sourceType = .photoLibrary
                picker.delegate = self
                picker.allowsEditing = true
                present (picker, animated: true, completion: nil)
            }
        }
// // Process to select photo from camera roll
// @IBAction func choosePicture () {
// // Is the camera roll available?
// if UIImagePickerController.isSourceTypeAvailable (.photoLibrary) {
// // View to select a photo
// let pickerView = UIImagePickerController ()
// // Select camera roll from photo source
// // ".camera" will start the camera
// pickerView.sourceType = .photoLibrary// // delegate
// pickerView.delegate = self
// // display in view
// self.present (pickerView, animated: true)
//}
//}
//

    // Process when user finishes shooting
    func imagePickerController (_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
        let image = info [UIImagePickerController.InfoKey.originalImage] as! UIImage
        self.imageView.image = image
        UIImageWriteToSavedPhotosAlbum (image, nil, nil, nil)
        self.dismiss (animated: true)
        UserDefaults.standard.set (image.jpegData (compressionQuality: 0.8), forKey: "MemoImage")
        saveData.synchronize ()
    }
    override func viewDidLoad () {
        super.viewDidLoad ()
// implement donebutton
                let kbToolBar = UIToolbar (frame: CGRect (x: 0, y: 0, width: 320, height: 40))
                kbToolBar.barStyle = UIBarStyle.default // set style
                kbToolBar.sizeToFit () // change the size to fit the screen width
                // spacer
                let spacer = UIBarButtonItem (barButtonSystemItem: UIBarButtonItem.SystemItem.flexibleSpace, target: self, action: nil)
                // Close button
                let commitButton = UIBarButtonItem (barButtonSystemItem: UIBarButtonItem.SystemItem.done, target: self, action: #selector (self.commitButtonTapped))
                kbToolBar.items = [spacer, commitButton]
                memoTextView.inputAccessoryView = kbToolBar
                imageView.isHidden = true
                // first image
                imageView.image = UIImage (named: "No-Image.PNG")
// imageView.isHidden = true
    }
    @objc func commitButtonTapped () {
           self.view.endEditing (true)
       }

    @IBAction func save (_ sender: Any) {
        let inputText = memoTextView.text
        let ud = UserDefaults.standard
        if ud.array (forKey: "memoArray")! = nil {
            var saveMemoArray = ud.array (forKey: "memoArray") as! [String]
            if inputText! = "" {
                // Add to array
                saveMemoArray.append (inputText!)
                ud.set (saveMemoArray, forKey: "memoArray")
            } else {
                showAlert (title: "Nothing entered")
            }
        } else {
            var newMemoArray = [String] ()
            if inputText! = "" {
                newMemoArray.append (inputText!)
                ud.set (newMemoArray, forKey: "memoArray")
            } else {
                showAlert (title: "Nothing entered")}
        }
        showAlert (title: "Save complete")
        ud.synchronize ()
    }
    func showAlert (title: String) {
        let alert = UIAlertController (title: title, message: nil, preferredStyle: .alert)
        alert.addAction (UIAlertAction (title: "OK", style: .default, handler: nil))
        alert.addAction (UIAlertAction (title: "Cancel", style: .cancel, handler: nil))
        self.present (alert, animated: true, completion: nil)
    }

        @IBAction func loadimageView () {
            print ("Reading start")
            swiftyTesseract.performOCR (on: imageView.image!) {recognizedString in
                guard let text = recognizedString else {return}
                print ("\ (text)")
                self.memoTextView.text = text
            }
        }
}
// tableViewCell on home screen
import UIKit

class TableViewCell: UITableViewCell {
    @IBOutlet weak var cellImage: UIImageView!
    @IBOutlet weak var cellLabel: UILabel!
    let uuid = NSUUID (). uuidString
    override func awakeFromNib () {
        super.awakeFromNib ()
// cellLabel.text = MemonoNakami
        let imageData: NSData = UserDefaults.standard.object (forKey: "saveImage") as! NSData
        cellImage.image = UIImage (data: imageData as Data)
        // Initialization code
    }
    override func setSelected (_ selected: Bool, animated: Bool) {
        super.setSelected (selected, animated: animated)
        // Configure the view for the selected state
    }
    // add here
    func fill (image: UIImageView, titleLb: String, date: String, siteName: String) {
        cellImage.image = imageView? .image
    }
    // add to
    override func prepareForReuse () {
        super.prepareForReuse ()
        cellImage.image = imageView? .image
    }
    func tableView (_ tableView: UITableView, cellForRowAt indexPath: IndexPath)->UITableViewCell {
            let cell = tableView.dequeueReusableCell (withIdentifier: "tableViewCell", for: indexPath) as! TableViewCell
            // initialize the image
// cellImage.image = nil
            return cell
    }

}

It is urgent. Thank you! !