I have this Fatal error(Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value: file), and the Xcode remind me it's this line has issue "let isEditable: Bool = isEditableSwitch.isOn" but you can see, it's not an optional value. Any one can help? by the way, I want use the On/Off status of a switch button to generate a bool value to show user whether the content is editable or not.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { super.prepare(for: segue, sender: sender) guard segue.identifier == "SaveUnwind" else { return } let title: String = titleTextField.text! let content: String = contentTextView.text ?? "" let createDate: Date = Date() let showDae: Date = dueDatePicker.date let image: UIImage? = contentImageView.image let isEditable: Bool = isEditableSwitch.isOn letter = Letter(title: title, content: content, image: image, createdDate: createDate, showDate: showDae, isEditable: isEditable) }
isEditableSwitchis probably an implicitly unwrapped interface builder outlet to aUISwitch(i.e.@IBOutlet var isEditableSwitch: UISwitch!) which you never hooked up. This has been asked thousands of times, please look search and look at the other answers