How to pass data from the initial launch of the NavController

I have an app that's using Dependency Injection to pass variable data. I followed the tutorial called "The Right Way to Share State Between Swift View Controllers" on the website "EnvatoTuts+" to the dot, but my initial view controller is a Navigation Controller. The AppDelegate is supposed to supply the initial view controller with an injection of my data-class called "ModelController", and then I pass it along through the different view controllers in my app.

How do I pass data from my NavController .class to the first screen that the users ever see, the "ViewController" class? I've never programmed a Navigation Controller and since it's only initially on the screen for that split second when the app launches and there's no buttons to press, I don't know how to make it execute a segue to send the information received from the AppDelegate to the ViewController that pops up when the app loads.

Here's my code:
Code Block
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        print("The app delegate launched.")        
        if let homeViewController = window?.rootViewController as? NavController {
            homeViewController.modelController = ModelController()
            print("App delegate homeViewController excecuted successfully.")
        }
        return true
    }
}


Code Block
class NavController: UINavigationController {
    
    var modelController: ModelController!
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        print("This is the NavController segue print test.")
        if let viewController = segue.destination as? ViewController {
            viewController.modelController = modelController
            print("NavViewController segue excecuted successfully.")
        }
    }
}


Code Block
class ViewController: UIViewController {
    var modelController: ModelController!
    }


Code Block
class ModelController {
    
    var thePDFInfo = pdfVariables(theClient: "N/A", theClaimNumber: "N/A", theFileNumber: "N/A", theLossDate: "N/A", theInsured: "N/A", theClaimant: "N/A", thePicsAreBy: "N/A", theDateTaken: "N/A")
    
}


Code Block
struct pdfVariables {
    let theClient: String
    let theClaimNumber: String
    let theFileNumber: String
    let theLossDate: String
    let theInsured: String
    let theClaimant: String
    let thePicsAreBy: String
    let theDateTaken: String
}

Why do you want to segue ?

You should pass data directly to the  topViewController (UIViewController) of the navigationController, without prepare.
Claude31, I changed it to simply pass to infoViewController from AppDelegate, instead of passing it through the others first. Here's the error I'm getting when I try to assign a new value to the variable in ModelController called "thePDFInfo":

"Unexpectedly found nil while implicitly unwrapping an Optional value." I don't understand why it's saying that there's an optional value... I haven't declared an optional value anywhere.

This is the code (simplified)... again the error comes on the line where I try to assign claimInfoData to modelController.thePDFInfo:

Code Block
class InfoViewController: UIViewController, UITextFieldDelegate {
    var modelController: ModelController!
@IBAction func infoDoneButton(_ sender: Any) {
let claimInfoData = pdfVariables(theClient: client, theClaimNumber: claimNumber, theFileNumber: fileNumber, theLossDate: lossDate, theInsured: insured, theClaimant: claimant, thePicsAreBy: picsBy, theDateTaken: dateTaken)
        modelController.thePDFInfo = claimInfoData
}
}

How to pass data from the initial launch of the NavController
 
 
Q