It's my first time creating an app with Xcode, and I have come across an error I can't figure out. The fatal error:
Thread 1: Fatal error: Unexpectedly found nil while implicitly unwrapping an Optional value, occurs on line 29.
I've seen other posts with comments saying "check your outlets", but they're all good. I've included the Connections inspector of one of my textfields in case it helps.
import UIKit
class ViewController: UIViewController, UITextFieldDelegate {
var mssgArray:[Int] = [0,0,0,0,0,0,0,0]
@IBOutlet weak var ItemQ: UITextView!
@IBOutlet weak var RTC: UITextView!
@IBOutlet weak var ExpoPrompt: UITextView!
@IBOutlet weak var OrderPrompt: UITextView!
@IBOutlet weak var Data: UITextView!
@IBOutlet weak var CusID: UITextField!
@IBOutlet weak var FirstN: UITextField!
@IBOutlet weak var LastN: UITextField!
@IBOutlet weak var PhoneNum: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
CusID.delegate = self
FirstN.delegate = self
LastN.delegate = self
PhoneNum.delegate = self
}
@IBAction func PizzaBut(_ sender: UIButton) {
if(mssgArray[0] == 0)
{
ItemQ.text += "Pizza\n"
mssgArray[0] = 1
}
if(mssgArray[0] == 1)
{
mssgArray[0] = 2
}
}
@IBAction func SubBut(_ sender: UIButton) {
if(mssgArray[1] == 0)
{
ItemQ.text += "Sub\n"
mssgArray[1] = 1
}
if(mssgArray[1] == 1)
{
mssgArray[1] = 2
}
}
@IBAction func QuesoBut(_ sender: UIButton) {
if(mssgArray[2] == 0)
{
ItemQ.text += "Queso\n"
mssgArray[2] = 1
}
if(mssgArray[2] == 1)
{
mssgArray[2] = 2
}
}
@IBAction func BagBut(_ sender: UIButton) {
if(mssgArray[3] == 0)
{
ItemQ.text += "Baguette\n"
mssgArray[3] = 1
}
if(mssgArray[3] == 1)
{
mssgArray[3] = 2
}
}
@IBAction func PretzelBut(_ sender: UIButton) {
if(mssgArray[4] == 0)
{
ItemQ.text += "Pretzels\n"
mssgArray[4] = 1
}
}
@IBAction func MeatballBut(_ sender: UIButton) {
if(mssgArray[5] == 0)
{
ItemQ.text += "Meatball\n"
mssgArray[5] = 1
}
if(mssgArray[5] == 1)
{
mssgArray[5] = 2
}
}
@IBAction func BoardBut(_ sender: UIButton) {
if(mssgArray[6] == 0)
{
ItemQ.text += "Charcuterie Board\n"
mssgArray[0] = 1
}
if(mssgArray[6] == 1)
{
mssgArray[6] = 2
}
}
@IBAction func SaladBut(_ sender: UIButton) {
if(mssgArray[7] == 0)
{
ItemQ.text += "Salad\n"
mssgArray[7] = 1
}
if(mssgArray[7] == 1)
{
mssgArray[7] = 2
}
}
@IBAction func ClearBut(_ sender: UIButton) {
ItemQ.text = ""
mssgArray = [0,0,0,0,0,0,0,0]
}
@IBAction func SendMssg(_ sender: UIButton) {
ItemQ.text = ""
mssgArray = [0,0,0,0,0,0,0,0]
}
@IBAction func AddCus(_ sender: UIButton) {
}
@IBAction func SearchCus(_ sender: UIButton) {
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
textField.resignFirstResponder()
return true
}
func textFieldDidBeginEditing(_ textField: UITextField) {
if(textField == CusID || textField == PhoneNum)
{
textField.keyboardType = UIKeyboardType.phonePad
}
}
}
And here is a screenshot of the two tab views and what I'm seeing, the right tab is showing the tab bar controller's controller inspector.