0

I'm making iOS Todo App but occur error is the title in AppDelegate.swift

I try to remove DetailViewController in Main.storyboard but the same error occurred

MemoListVC.swift

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {

    let row = self.appDelegate.memolist[indexPath.row]

    guard let vc = self.storyboard?.instantiateViewController(withIdentifier: "MemoRead") as? MemoReadVC else {
      return
    }

MemoDetailVC.swift

import UIKit

class MemoDetailVC: UITableViewController {

    var param: MemoData?

    @IBOutlet var subject: UILabel!
    @IBOutlet var contents: UILabel!
    @IBOutlet var img: UIImageView!

    override func viewDidLoad() {
        super.viewDidLoad()

        // Uncomment the following line to preserve selection between presentations
        // self.clearsSelectionOnViewWillAppear = false
        // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
        // self.navigationItem.rightBarButtonItem = self.editButtonItem

        self.subject.text = param?.title
        self.contents.text = param?.contents
        self.img.image = param?.image

        let formatter = DateFormatter()
        formatter.dateFormat = "dd일 HH:mm"
        let dateString = formatter.string(from: (param?.date)!)

        self.navigationItem.title = dateString
    }

}

AppDelegate.swift

import UIKit
import CoreData

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?
    var memolist = [MemoData]() 

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        return true
    }

error

2019-08-25 02:30:08.049965+0900 MyMemory[39157:1944071] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "MemoDetail" from storyboard "Main", but didn't get a 

1 Answers1

0

In MemoListVC.swift, I noticed that you instantiated the view controller with identifier "MemoRead". Is this identifier identical to the one you set for the view controller you want to instantiate, but in the storyboard? If not, that might be what is throwing your code off.

If it isn't identical, then go to the storyboard, select the view controller, and go to the identity inspector (3rd icon from the left in Xcode 10) on the inspector sidebar on the right, and change the name of the identifier you are using to instantiate, in the MemoListVC.swift, to the one that is listed in the storyboard identity inspector under "Storyboard ID".

Pranav Ramesh
  • 780
  • 1
  • 5
  • 9