I Have the following constants which I want to use across my app:
let greenColor = UIColor(red: 173.0/255.0, green: 179.0/255.0, blue: 55.0/255.0, alpha: 1.0)
let goldColor = UIColor(red: 190.0/255.0, green: 164.0/255.0, blue: 104.0/255.0, alpha: 1.0)
let purpleColor = UIColor(red: 77.0/255.0, green: 92.0/255.0, blue: 165.0/255.0, alpha: 1.0)
let whiteColor = UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1.0)
However when I segue from ViewController which is a modally presented to another View controller I get the error above
Unexpectedly found nil while unwrapping an Optional value
The code I use for the segue is:
weak var pvc = self.presentingViewController
self.dismiss(animated: true, completion: {
pvc?.present(AppHome(), animated: true, completion: nil)
})
I am stumped can someone tell me what I am doing wrong here?
EDIT
As per @rmaddy's suggestion the code that is causing the crash is this:
import UIKit
class AppHome: UIViewController {
@IBOutlet weak var optionOneButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
optionOneButton.setButtonStyle(button: optionOneButton, color: purpleColor, title: "Current Knowledgebase")
}
Here is an image of the error and the helper output in xCode: