let saveNewItem = SaveNewItem()
print(saveNewItem)
if saveNewItem != nil {
print("Contains a value!")
_ = UIApplication.shared.keyWindow!.rootViewController
self.present(saveNewItem, animated: true, completion: nil)
} else {
print("Doesn’t contain a value.")
}
I am receiving the infamous: fatal error: unexpectedly found nil while unwrapping an Optional value
on my saveNewItem declaration, which is a call to a different viewcontroller: SaveNewItem from the main one calling this.
I'm confused why this is return nil when the print statement is stating it has a value store in the declaration.
a bypass I figured out to continue the process was to inspect (cmd+click) the saveNewItem constant to which it reproduces in the console my print statement, which gives the impression it creates an object.
I've also tried linking the viewcontroller using the storyboard as demonstated in this question: How to connect ViewController.swift to ViewController in Storyboard?