Thread 1: "Application tried to present modally a view controller that is already being presented by <UINavigationController

I am getting an error that crashes my app and takes me to AppDelegate file showing an error message

Thread 1: "Application tried to present modally a view controller <MyApp.CanvasViewController: 0x7fca1c70f610> that is already being presented by <UINavigationController: 0x7fca1d837800>

Basically what I was trying to do was to save an instance of UIViewController into app delegate protocol and then show every saved instance into a UITableView cell in which each cell will have a button to go back to that instance of the UIViewController.

@objc func actbuttonFuncCall(_ sender: UIButton) {

    let index = sender.tag
    
    // access the content of the singleton class where the struct.view: UIVIewController is saved

    let identifier = VCs.shared.storedVc[index]?.view
    
    let vc = identifier
    
    print("tool bar button clicked! \(vc)")
    vc?.modalPresentationStyle = .fullScreen
    vc?.modalTransitionStyle = .coverVertical
    
    // set main CanvasViewController as default value
    present(vc ?? CanvasViewController(), animated: true)
}

That is to allow users to go back and forward into the main UIViewController where all the project functionality is executed. Is there anything I should consider doing to achieve my goal?

Yes, you should consider doing it correctly.

Thread 1: "Application tried to present modally a view controller that is already being presented by &lt;UINavigationController
 
 
Q